-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
If we have a simple query, with only a SelectionSet:
{
hero {
name
}
}
which is the same as
query HeroNameQuery {
hero {
name
}
}
The tests in graphql.js show this expected answer:
{
data: {
hero: {
name: 'R2-D2'
}
}
}
I know we can have many root in one query:
query FetchLukeAndLeiaAliased {
luke: human(id: "1000") {
name
}
leia: human(id: "1003") {
name
}
}
Resulting in this answer:
{
data: {
luke: {
name: 'Luke Skywalker'
},
leia: {
name: 'Leia Organa'
}
}
}
But, and it's my main concern, what if we have more that one operation in one query, which seems to be valid in the specifications (examples in http://facebook.github.io/graphql/#sec-All-Variable-Uses-Defined and http://facebook.github.io/graphql/#sec-All-Variables-Used).
For example what is the expected answer for this graphql query (dumb query just for the example):
query LukeAndLeiaNames {
luke: human(id: "1000") {
name
}
leia: human(id: "1003") {
name
}
}
query LukeAndLeiaHomePlanet {
luke: human(id: "1000") {
homePlanet
}
leia: human(id: "1003") {
homePlanet
}
}
I currently have no idea, except that there should be one more level between data and a query result using the name of the operation (which must be unique in the document, as said in the specification).
Or each query have its own "object" response, with data, errors... But in this case how are they "encapsulated"? In a main object with the operation names used as keys ? I could not find anything about this in the specification or the graphql.js tests.
Thanks for your answer, I'm currently writing a python graphql server and it will help me to know that ;)