- I'm trying to query for a subset of attributes from documents but failing. https://discord.com/channels/564160730845151244/1190627623907364965 This question about using queries in GraphQL to filter the database attributes is not answered and the docs around that are fuzzy at best. Below is the JSON request body I'm using for this request.
- Also, for the Appwrite cloud, is there a URL for the GraphQL Explorer? I see some tutorials around that for local instances, but no reference for cloud.
[
{
"query": "query($databaseId: String!, $collectionId: String!) { databasesListDocuments( databaseId: $databaseId, collectionId: $collectionId, queries: [ {'method': 'select', 'attributes': ['first_name', 'last_name'] } ] ) { total documents { _id _collectionId _databaseId _createdAt _updatedAt _permissions data } }}",
"variables": {
"databaseId": "onlinestore-xyz",
"collectionId": "customers"
}
}
]
Also, for the Appwrite cloud, is there a URL for the GraphQL Explorer? You can set up the GraphQL explorer locally and point it to Cloud. You won't get the references/docs, though as those are disabled on cloud
Is this what you are talking about: https://github.com/appwrite/docker-altair ?
oh we don't support selecting attributes for our graphql implementation
typically, a graphql api won't require passing select queries. you would just specify which attributes you want returned
you actually might be able to get the lmited attributes returned with that select query...
Right, how can I do that?
what's happening though?
Well, I feel that the queries is being ignored altogether and it always returns the full document. I even tried to list the attribute names instead of the data in the document attribute list.
one thing that could be a problem is:
{'method': 'select', 'attributes': ['first_name', 'last_name'] }
this isn't valid JSON. and, it should be stringified
By the way, I'm not even sure if the attributes term can be used or not, I just guessed based on the examples here: https://appwrite.io/docs/products/databases/queries#building-queries. Like I said, the documentation around this is sparse.
ahhh good point. it should be values
Same result with queries: [ \"{\"method\": \"select\", \"values\": [\"first_name\", \"last_name\"] }\"]
This worked for me:
{
databasesListDocuments(
databaseId: "default"
collectionId: "usernames"
queries: ["{\"method\":\"select\",\"values\":[\"username\"]}"]
) {
total
documents {
data
_id
_collectionId
_databaseId
_createdAt
_updatedAt
_permissions
}
}
}
the raw payload ended up being:
{
"query": "\n{\n databasesListDocuments(\n databaseId: \"default\"\n collectionId: \"usernames\"\n queries: [\"{\\\"method\\\":\\\"select\\\",\\\"values\\\":[\\\"username\\\"]}\"]\n ) {\n total\n documents {\n data\n _id\n _collectionId\n _databaseId\n _createdAt\n _updatedAt\n _permissions\n }\n }\n}\n",
"variables": {},
"operationName": null
}
Cool. Let me try.
Recommended threads
- Functions not executing after usage rese...
Hi team, Last month my project hit 100% usage and functions stopped working (expected). Now the new month has started and usage has reset, requests are going ...
- Relations within the same table
Hello, I'm currently building a sort of dictionary (a literal one) and thus I need words (which is one single table of words in my database) to be able to have ...
- Functions never end and always fail (sta...
Hi ! I'm using Appwrite Cloud Pro and function execution from appwrite website is KO. Deploying starter function template, execution is always Failed and the ...