Lone Anonymous Operation
Formal Specification
- Let operations be all operation definitions in the document.
- Let anonymous be all anonymous operation definitions in the document.
- If
operations
is a set of more than 1:
- anonymous must be empty.
Explanatory Text
GraphQL allows a short‐hand form for defining query operations when only that one operation exists in the document.
For example the following document is valid:
{
dog {
name
}
}
While this document is invalid:
{
dog {
name
}
}
query getName {
dog {
owner {
name
}
}
}