
How do u make multiple request inside one graphql request with Appwrite and NextJS, there is my code :
const q = (await graphql.query([
{
query: `query {
databasesListDocuments(
databaseId: "${String(process.env.NEXT_PUBLIC_APPWRITE_DATABASE_USERS)}",
collectionId: "${String(process.env.NEXT_PUBLIC_APPWRITE_COLLECTION_MOVIE_LIKED)}",
queries: ["equal('userId', ${userId})", "equal('movieId', ${movieId})"]
) {
total
documents {
_id
_collectionId
_databaseId
_createdAt
_updatedAt
_permissions
data
}
}
}`
}
]))
Here I only take the likes from a specific user and specific movie. Now I also want to get the "asSeen" state from another collection, how can I do ?

I saw some exmaple like this :
query getAuthors {
authors {
firstName
lastName
}
}
// Query to get all posts
query getPosts {
posts {
id
title
exert
}
}
But how add custom name from each call ? like "getAuthors", "getPosts"

I dont understand the utility of "operationName" if I can call multiple operationName :/

from "Appwrite GraphQL Overview" (youtube video) I also dont understand how he got custom name like this

what do you mean? you can put whatever you like

these are not custom names. these are method calls

here's an example: https://appwrite.io/docs/graphql#query-batching

well there is something I dont understand ahah, how can I do multiple listDocument (for getting likes and "asSeen" state for example) :

const q = await graphql.query(
{
query: `
query GetAction {
databasesListDocuments(
databaseId: "${String(process.env.NEXT_PUBLIC_APPWRITE_DATABASE_USERS)}",
collectionId: "${String(process.env.NEXT_PUBLIC_APPWRITE_COLLECTION_MOVIE_LIKED)}",
queries: ["equal('userId', ${userId})", "equal('movieId', ${movieId})"]
) {
total
documents {
_id
_collectionId
_databaseId
_createdAt
_updatedAt
_permissions
data
}
}
databasesListDocuments(
databaseId: "${String(process.env.NEXT_PUBLIC_APPWRITE_DATABASE_USERS)}",
collectionId: "${String(process.env.NEXT_PUBLIC_APPWRITE_COLLECTION_MOVIE_WATCHED)}",
queries: ["equal('userId', ${userId})", "equal('movieId', ${movieId})"]
) {
total
documents {
_id
_collectionId
_databaseId
_createdAt
_updatedAt
_permissions
data
}
}
}
`,
}
)
console.log('graphql', q)

because in my code ive got this error :
"Fields "databasesListDocuments" conflict because they have differing arguments. Use different aliases on the fields to fetch both if this was intentional."

maybe this will help: https://atheros.ai/blog/how-to-use-graphql-aliases

Ive got this error because I use two time databasesListDocuments
but ive no other choice :/

did you look at what i linked?

Query batching ? yes but in the example they use method call "accountGet" and "localeGet" but no databaseslistdocuments

I guess there is something I dont understand

i meant this...

yeah they add custom name for each call like this :
likes: databasesListDocuments(
databaseId: "${String(process.env.NEXT_PUBLIC_APPWRITE_DATABASE_USERS)}",
collectionId: "${String(process.env.NEXT_PUBLIC_APPWRITE_COLLECTION_MOVIE_LIKED)}",
queries: ["equal('userId', ${userId})", "equal('movieId', ${movieId})"]
) {
total
documents {
_id
_collectionId
_databaseId
_createdAt
_updatedAt
_permissions
data
}
}
watch: databasesListDocuments(
databaseId: "${String(process.env.NEXT_PUBLIC_APPWRITE_DATABASE_USERS)}",
collectionId: "${String(process.env.NEXT_PUBLIC_APPWRITE_COLLECTION_MOVIE_WATCHED)}",
queries: ["equal('userId', ${userId})", "equal('movieId', ${movieId})"]
) {
total
documents {
_id
_collectionId
_databaseId
_createdAt
_updatedAt
_permissions
data
}
}
but when i do that im getting Max query complexity should be 250 but got 450
😢
The only way to dont have this error is delete some output result (like _collectionId
, _createdAt
, etc...)

Well I guess its okay I dont need all these data

But why there is a limit ? ive weed need a lot of result how can we do it ?

you can also modify the complexity: https://appwrite.io/docs/environment-variables#graphql

ohhh mb ahah

[SOLVED] Starting with GraphQL
Recommended threads
- 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...
- Appwrite stopped working, I can't authen...
I'm having an issue with Appwrite. It was working fine just a while ago, but suddenly it stopped working for me and can't authenticate accounts. I even went bac...
- Fail to receive the verification email a...
I added my email address to prevent it from showing "appwrite," but now I'm not receiving emails for verification or password resets. The function appears to be...
