-
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
base: main
Are you sure you want to change the base?
Changes from all commits
10cbf4b
b14e553
20e079f
8275f38
a8deaa7
6cc1806
28e9bbc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -1096,15 +1096,49 @@ 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 | ||||||||
| 3. Any non-repeatable directives provided must not already apply to the previous | ||||||||
| Object type. | ||||||||
| 5. Any interfaces provided must not be already implemented by the previous | ||||||||
| 4. 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 | ||||||||
| 5. The resulting extended object type must be a super-set of all interfaces it | ||||||||
| implements. | ||||||||
|
|
||||||||
| #### Field Extensions | ||||||||
|
|
||||||||
| Field extensions are used to represent a field which has been extended from some | ||||||||
| previously defined field. For example this may be used by a GraphQL service | ||||||||
| which is itself an extension of another GraphQL service. When the same field | ||||||||
| appears in multiple extensions, the properties are merged with later extensions | ||||||||
| taking precedence for conflicting values. | ||||||||
|
|
||||||||
| In this example, we can deprecate the field `field` on type `Query` by using a | ||||||||
| field extension: | ||||||||
|
Comment on lines
+1114
to
+1115
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. Same here. I'd phrase that as a "type extension that adds deprecation to the type fields":
Suggested change
|
||||||||
|
|
||||||||
| ```graphql example | ||||||||
| type Query { | ||||||||
| field: String | ||||||||
| } | ||||||||
| ``` | ||||||||
|
|
||||||||
| ```graphql example | ||||||||
| extend type Query { | ||||||||
| field: String @deprecated(reason: "Use newField") | ||||||||
| } | ||||||||
| ``` | ||||||||
|
|
||||||||
| ** Type Validation ** | ||||||||
|
|
||||||||
| Fields have the potential to be invalid if incorrectly defined. | ||||||||
|
|
||||||||
| 1. The field type must match the previous definition exactly | ||||||||
| 2. The default argument definitions may not be changed or removed. | ||||||||
| 3. The description may be added if none exists, or must match the existing | ||||||||
| description exactly | ||||||||
|
Comment on lines
+1134
to
+1136
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. Can we either:
Slight preference for 1. because it's consistent with what we do for checking the type. But I can see how 2. is maybe simpler to implement. |
||||||||
| 4. The deprecation reason may be added if none exists, or must match the | ||||||||
| existing reason exactly | ||||||||
| 5. Directives may be added but cannot conflict with existing non-repeatable | ||||||||
| directives | ||||||||
|
Comment on lines
+1137
to
+1140
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. I think we should remove 4. as a sub-case of 5. |
||||||||
|
|
||||||||
| ## Interfaces | ||||||||
|
|
||||||||
| InterfaceTypeDefinition : | ||||||||
|
|
@@ -1358,6 +1392,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. | ||||||||
|
|
||||||||
| ```graphql example | ||||||||
| interface Node { | ||||||||
| id: ID | ||||||||
| } | ||||||||
|
|
||||||||
| extend interface Node { | ||||||||
| id: ID @deprecated(reason: "Use globalId instead") | ||||||||
| } | ||||||||
| ``` | ||||||||
|
|
||||||||
| ## Unions | ||||||||
|
|
||||||||
| UnionTypeDefinition : Description? union Name Directives[Const]? | ||||||||
|
|
||||||||
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.
Nit: move this before the Type Validation and do not mention "Field extensions"?
Instead make a part of "type extension"?