-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Field extensions: spec edits #1196
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
Draft
egoodwinx
wants to merge
9
commits into
graphql:main
Choose a base branch
from
egoodwinx:field-extension
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
10cbf4b
add initial outline for field extensions
egoodwinx b14e553
address pr comments
egoodwinx 20e079f
minor formatting changes
egoodwinx 8275f38
Merge branch 'main' into field-extension
egoodwinx a8deaa7
update to match current graphql-js implementation
egoodwinx 6cc1806
update description for default values, not all arguments
egoodwinx 28e9bbc
fix grammar
egoodwinx 29ef5bb
combine field extensions into object extensions
egoodwinx 2645e07
address comments, remove interface field extensions, and add more con…
egoodwinx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1089,20 +1089,41 @@ In this example, a directive is added to a `User` type without adding fields: | |
| extend type User @addedDirective | ||
| ``` | ||
|
|
||
| Object type extensions may choose to extend existing fields. | ||
|
|
||
| In this example, we can deprecate the field `id` on type `Query` by adding a | ||
| `@deprecated` directive through a type extension: | ||
egoodwinx marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```graphql example | ||
| type Query { | ||
| id: String | ||
| } | ||
| ``` | ||
|
|
||
| ```graphql example | ||
| extend type Query { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in this world, |
||
| id: String @deprecated(reason: "Use newId") | ||
| } | ||
| ``` | ||
|
|
||
| **Type Validation** | ||
|
|
||
| Object type extensions have the potential to be invalid if incorrectly defined. | ||
|
|
||
| 1. The named type must already be defined and must be an Object type. | ||
| 2. The fields of an Object type extension must have unique names; no two fields | ||
| may share the same name. | ||
| 3. Any fields of an Object type extension must not be already defined on the | ||
| previous Object type. | ||
| 4. Any non-repeatable directives provided must not already apply to the previous | ||
| 2. For each field of an Object type extension: | ||
| 1. The field must have a unique name within that Object type extension; no | ||
| two fields may share the same name. | ||
| 2. If a field with the same name exists on the previous Object type: | ||
| 1. The field type must match the previous definition exactly. | ||
| 2. The argument definitions defaultValues must match. | ||
| 3. The description or deprecation may be added if none exists, or must | ||
| match the existing description or deprecation exactly. | ||
| 4. Directives may be added but cannot conflict with existing | ||
| non-repeatable directives. | ||
| 3. Any interfaces provided must not be already implemented by the previous | ||
martinbonnin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Object type. | ||
| 5. Any interfaces provided must not be already implemented by the previous | ||
| Object type. | ||
| 6. The resulting extended object type must be a super-set of all interfaces it | ||
| 4. The resulting extended object type must be a super-set of all interfaces it | ||
| implements. | ||
egoodwinx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## Interfaces | ||
|
|
@@ -1358,6 +1379,21 @@ defined. | |
| 6. The resulting extended Interface type must be a super-set of all Interfaces | ||
| it implements. | ||
|
|
||
| #### Interface Field Extensions | ||
|
|
||
| Interface field extensions follow the same rules as Object field extensions and | ||
| are used to extend fields on interface types. | ||
egoodwinx marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```graphql example | ||
| interface Node { | ||
| id: ID | ||
| } | ||
|
|
||
| extend interface Node { | ||
| id: ID @deprecated(reason: "Use globalId instead") | ||
| } | ||
| ``` | ||
|
|
||
| ## Unions | ||
|
|
||
| UnionTypeDefinition : Description? union Name Directives[Const]? | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.