Open rmosolgo opened 8 years ago
As a side note I think it's reasonable to have a server with only mutation or subscription types, I'm not sure why Query is singled out as being required.
Agreed. We've been bitten by this when exposing mutation-only schemas for backend services. The workaround is to create an empty query type, but I'm not sure what the rationale is for that to be explicitly required unlike mutationType
or subscriptionType
. Does queryType
have any other special characteristics?
To be clear, the issue at hand is the non-nullability of the queryType
field in the Introspection schema:
A GraphQL schema must have a query root, but mutation and subscription roots are optional. If a schema doesn't have a mutation root,
mutation
operations are invalid. Same forsubscription
: if there's nosubscription
root type, we should reject a document with an operation onsubscription
.We have this validation in graphql-ruby now (thanks @cjoudrey) but we didn't at first, because I was literally reading the spec and implementing the rules one-by-one.
Should that rule be in the spec? If so, I'm happy to try writing up (I think I have a bow tie around here somewhere 😆 ).