-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix ambiguity around when schema definition may be omitted #987
Conversation
✅ Deploy Preview for graphql-spec-draft ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
I've submitted a larger edit that I think improves accuracy and makes reading (and referencing) easier by using a definition. |
@leebyron "default root type name" read better in context than "default operation type name" so I've gone with that. If you approve, I think this is ready to merge 👍 |
@graphql/tsc I'm going to add this to Thursday's WG, a review/merge before then would make the discussion shorter 😉 |
Marking this as a Proposal since this is a meaningful change. Two changes here:
The test case we need to see is your description above: when putting SDL in to in-memory, then back to SDL, does a non-root type named "Mutation" end up in the right place? |
@graphql/implementers Please could you add the following to your test suites, and report back if there are any issues:
type Query {
viruses: [Virus!]
}
type Virus {
name: String!
knownMutations: [Mutation!]!
}
type Mutation {
name: String!
geneSequence: String!
}
schema {
query: Query
} I've raised a PR against GraphQL.js that you can use for inspiration: graphql/graphql-js#3839 |
@benjie I have added the described test case in webonyx/graphql-php#1303. Constructing the schema from your example SDL worked fine, it did correctly not support mutations. I had to make the same fix as you did in |
This PR implements the tests and fixes necessary for [Spec RFC #987](graphql/graphql-spec#987). This PR is made of three main commits: 1. Test printing a schema that has `Query`, `Mutation` and `Virus` types, but only supports `query` operations (via the `Query` type) and does _not_ support `mutation` operations. 2. Test parsing this same schema text, and assert that the schema does not have a mutation type. 3. Fix the printing of the schema. Co-authored-by: Lee Byron <[email protected]>
Necessary code changes looks great, key decisions look correct, good feedback from implementers - this is now RFC 2 |
Would love feedback on my edits @benjie
|
7f0f3d3
to
e228161
Compare
spec/Section 3 -- Type System.md
Outdated
While this example describes a valid GraphQL schema which happens to contain a | ||
type called {"Mutation"} which is not the {`mutation`} _root operation type_. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reads awkwardly, I think simply removing While
would fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reworded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better; spot on 👍
@leebyron Looks good to me! While we're at it... do you think we should rename "root operation type" to simply "root type"? That would fit better with "default root type name", and I don't think it loses clarity. |
Yes this would be clarifying but to keep this one from expanding further I'll do a follow up |
0ae0071
to
1684fde
Compare
1684fde
to
8d55c5c
Compare
8d55c5c
to
058b4ec
Compare
@rivantsov Pointed out in #978 that there's some ambiguity around when the
schema
keyword can be omitted from the SDL. Upon careful reading I've noticed that there is additional ambiguity around this topic.This seems to imply that all the root types are required in order to omit the schema definition. I've modified the text to indicate that the names only need to match for the root types that are actually present.
Imagine we're doing biological research, tracking mutations in a virus. We might have a schema like:
In this case we must not omit the schema definition when representing the schema using the SDL, because doing so would make it seem that the Mutation type was the root type for the mutation operation, when in fact the schema does not support a mutation operation.
I've clarified the wording to deal with this possibility too.