Merging Queries
costag1982 opened this issue · 2 comments
costag1982 commented
Hi its not really an issue more of question and if the answer is no then a feature request
query gamesAndLeagues {
games(query: {result: "void"}) {
teamOne {
id
}
teamTwo {
id
}
result
}
leagues(query: {vip: false}) {
_id
}
}
this is a query i hit to get data from mongodb realms via gql.
I was wondering if it is possible to build this query that calls 2 collections via a single call?
Im thinking its not possible based on the docs
Thanks
dkhrunov commented
Same question!
@costag1982 did you find a solution?
dkhrunov commented
@costag1982 I'm found it
const query = gql.query(
[
{
operation: { name: 'getUser', alias: 'getAdminUser' },
variables: { id: 1 },
fields: ['id', 'name', 'role']
},
{
operation: { name: 'getSomething', alias: 'getAdminSomething' },
variables: { somthingId: 99 },
fields: ['id', 'name', 'description']
}
]
);
Result:
{
"query": "query ($id: Int, $somthingId: Int) { getAdminUser: getUser (id: $id) { id, name, role } getAdminSomething: getSomething (somthingId: $somthingId) { id, name, description } }",
"variables": {
"id": 1,
"somthingId": 99
}
}