- 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
- Type Mismatch in AppwriteException
There is a discrepancy in the TypeScript type definitions for AppwriteException. The response property is defined as a string in the type definitions, but in pr...
- [SOLVED] OAuth With Google & Flutter
Hi all, I'm trying to sign in with google and it all goes swimmingly until the call back. I get a new user created on the appwrite dashboard however the flutte...
- What Query's are valid for GetDocument?
Documentation shows that Queries are valid here, but doesn't explain which queries are valid. At first I presumed this to be a bug, but before creating a githu...