- 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
- Weird permission failure
when creating an account I use following methods: ``` Future<void> register(String email, String password, String username) async { final user = await accoun...
- Appwrite Storage error 503s for automate...
I'm facing error 503s from Appwrite after about 5-6 seconds of making AI requests from my tool with images and files above 20MB (=> not inline base64 used, but ...
- Flutter Android oAuth is no more working
I currently don't get the oAuth login to work in flutter android. it works on ios and on web. but when try to use it on Android, i get to the point where the ca...