-
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
RFC: SchemaExtension #428
RFC: SchemaExtension #428
Conversation
This adds support for graphql/graphql-spec#428 spec proposal. So far this just adds language support and updates validation rules to be aware of this new ast node. I'll follow up with support in `extendSchema()` and tests.
This adds new grammar to the GraphQL SDL: ```graphql extend schema { mutation: MutationType } ``` This feels like the missing piece of the type system extension framework. In addition to extending types in a type system, the top level schema should be extendable as well.
a52ecc5
to
a86d3d0
Compare
👍 I also got the same feeling after working with other extensions for a while. On a side note (but I think it is a bit related), I wanted to ask about another limitation that was added at some point: [RFC] Add Validation rule for unique directives per location. From the moment this validation was introduced, I felt that it was quite limiting. Considering that now there is a good support for splitting the schema across multiple files, I think that it might be a good idea to reassess this validation. Do you think it makes sense to reconsider it? (I personally would vote in favor of removing it or, at least, limiting the validation to a subset of directives) Just to give a small example where it might be helpful. Considering the schema delegation case where multiple GraphQL schemas are merged into one. I can define the config like this: https://github.com/OlegIlyenko/graphql-gateway/blob/master/testSchema.graphql#L6-L16 With the new extension I can potentially split the schema in 2 files: # file 1
schema
@includeGraphQL(
name: "starWars",
url: "http://try.sangria-graphql.org/graphql") {
query: Query
}
# file 2
extend schema
@includeGraphQL(
name: "universe",
url: "https://www.universe.com/graphql/beta") But even if directives are not split across different extensions, I would still find it helpful to be able to use the same directive multiple times (with different arguments) at the same location. |
That's certainly something we could reconsider. I remember when applying that rule we did so intentionally to carve out the space for future exploration. Would you mind creating a new issue about that topic where we can discuss further? |
Sure thing, I'll create a new issue 👍 |
I created a separate issue for this: Limiting the scope of "Directives Are Unique Per Location" validation |
This adds support for graphql/graphql-spec#428 spec proposal. So far this just adds language support and updates validation rules to be aware of this new ast node. I'll follow up with support in `extendSchema()` and tests.
Leaving this open for review for a shorter period of time - I hope this is an easy win :) |
Thanks for the online and offline feedback everyone! |
* RFC: SchemaExtension This adds support for graphql/graphql-spec#428 spec proposal. So far this just adds language support and updates validation rules to be aware of this new ast node. I'll follow up with support in `extendSchema()` and tests. * Support extendSchema() * Formatting edits * Add parsing and validation tests * Adjust grammar rules to match spec definitions
This adds new grammar to the GraphQL SDL:
This feels like the missing piece of the type system extension framework. In addition to extending types in a type system, the top level schema should be extendable as well.