
- 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
- Getting issue while migrating from Self ...
i try to migrating my project but when do this error come and dont allow to crate that migration
- Pending upload some file, but not for ot...
When upload this file, always got pending. But when I upload another file, it works. Why?
- Need help setting up this error is showi...
You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy. If you're the app developer, register the redirect URI in the Google Cl...
