feat(validation): reject directive definition cycles - rewrite #4726#4816
Open
yaacovCR wants to merge 1 commit into
Open
feat(validation): reject directive definition cycles - rewrite #4726#4816yaacovCR wants to merge 1 commit into
yaacovCR wants to merge 1 commit into
Conversation
|
@yaacovCR is attempting to deploy a commit to the The GraphQL Foundation Team on Vercel. A member of the Team first needs to authorize it. |
…l#4726 Adds a new `NoDirectiveDefinitionCyclesRule` SDL validation rule that detects cycles in the graph of directives used within directive definitions. A cycle arises when following the references within directive definitions leads back to the same directive. Two kinds of references are tracked: 1. **Directive argument types** — if `@foo` takes an argument of type `InputObject`, and `InputObject` has a field with directive `@foo`, that forms a cycle: `@foo → InputObject → @foo`. 2. **Directives on directive definitions** — when the experimental `experimentalDirectivesOnDirectiveDefinitions` parser option is enabled, a directive applied directly to a directive definition or extension is also a reference. If `@a` is annotated with `@b` and `@b` is annotated with `@a`, that is a cycle: `@a → @b → @a`. Cycles make it impossible to build a well-defined schema; the spec already [forbids them](https://spec.graphql.org/draft/#sec-Type-System.Directives.Type-Validation), and experimental directive extensions [do the same](https://github.com/graphql/graphql-spec/pull/1206/changes#diff-30a69c5a5eded8e1aea52e53dad1181e6ec8f549ca2c50570b035153e2de1c43R2342).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new
NoDirectiveDefinitionCyclesRuleSDL validation rule that detects cycles in the graph of directives used within directive definitions.A cycle arises when following the references within directive definitions leads back to the same directive. Two kinds of references are tracked:
@footakes an argument of typeInputObject, andInputObjecthas a field with directive@foo, that forms a cycle:@foo → InputObject → @foo.experimentalDirectivesOnDirectiveDefinitionsparser option is enabled, a directive applied directly to a directive definition or extension is also a reference. If@ais annotated with@band@bis annotated with@a, that is a cycle:@a → @b → @a.Cycles make it impossible to build a well-defined schema; the spec already forbids
them, and experimental directive extensions do the
same.