-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What makes a schema "be defined"? #682
Comments
We (apollo-rs team) discussed this and agreed that we should align with other implementations and make the test case above valid. But what does this mean for the data structure? Should schema { query: MyQuery }
type MyQuery { … }
type Mutation { … } schema { query: Query }
type Query { … }
type Mutation { … } Which of these schemas have a mutation root operation? If neither, I think we need an |
According to graphql/graphql-spec#987 neither of the last two cases above have a mutation root operation. However I think we can still remove the |
GraphQL has unfortunate name overloading. I will call:
TypeSystemExtensionDocument
SchemaDefinition
that starts with theschema
keywordSpec divination
SchemaExtension
starts with theextend schema
keywords and has validation rules:“Schema” in the first rule is capitalized but not a link. My interpretation of this rule is: a
SchemaDefinition
must exist.Separately, Default Root Operation Type Names specifies:
Unfortunately this is written from the point of view of SDL authors (or authoring tools), and only suggests by implication what’s expected of tools reading SDL. My interpretation is: in the absence of a
SchemaDefinition
, root operations are defined based on whichtype Query {…}
,type Mutation {…}
, ortype Subscription {…}
are defined.1.0 beta 1 behavior
Based on the above, I implemented apollo-compiler 1.0.0-beta.1 such that:
Schema::schema_definition
is anOption
, set toSome
ifSchemaDefinition
exists. It contains stuff from thatSchemaDefinition
and anySchemaExtension
Schema::root_operation
method looks either atschema_definition
if it’sSome
, or at which object types exist if it’sNone
Test case
1.0.0-beta.1 records an error for
extend schema
without aschema
definition, and setsSchema::schema_definition
toNone
. The extension and its directive application are ignored.Reportedly, the behavior of some other tools is that
type Query
creates a sort of implicit schema definition, which means that "the schema is defined" for the purpose ofextend schema
validation, so the extension and its directive application are accounted for.What behavior do we want?
The text was updated successfully, but these errors were encountered: