Skip to content

Commit 10cbf4b

Browse files
committed
add initial outline for field extensions
1 parent 96271da commit 10cbf4b

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

spec/Appendix C -- Grammar Summary.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,12 @@ FieldsDefinition : { FieldDefinition+ }
318318
FieldDefinition : Description? Name ArgumentsDefinition? : Type
319319
Directives[Const]?
320320

321+
FieldExtension :
322+
323+
- extend field MemberCoordinate ImplementsInterfaces? Directives[const]?
324+
[lookahead != `{`]
325+
- extend field description MemberCoordinate [lookahead != `{`]
326+
321327
ArgumentsDefinition : ( InputValueDefinition+ )
322328

323329
InputValueDefinition : Description? Name : Type DefaultValue? Directives[Const]?
@@ -329,6 +335,10 @@ InterfaceTypeDefinition :
329335
- Description? interface Name ImplementsInterfaces? Directives[Const]?
330336
[lookahead != `{`]
331337

338+
InterfaceFieldExtension :
339+
340+
- extend interface MemberCoordinate Directives[const]?
341+
332342
InterfaceTypeExtension :
333343

334344
- extend interface Name ImplementsInterfaces? Directives[Const]?

spec/Section 3 -- Type System.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,36 @@ Object type extensions have the potential to be invalid if incorrectly defined.
11051105
6. The resulting extended object type must be a super-set of all interfaces it
11061106
implements.
11071107

1108+
### Field Extensions
1109+
1110+
FieldExtension :
1111+
1112+
- extend field MemberCoordinate ImplementsInterfaces? Directives[const]?
1113+
[lookahead != `{`]
1114+
- extend field description MemberCoordinate [lookahead != `{`]
1115+
1116+
Field extensions are used to represent a field which has been extended from some
1117+
previously defined field. For example this may be a GraphQL service which is
1118+
itself an extension of another GraphQL service.
1119+
1120+
In this example, we can deprecate the id field on the User type.
1121+
1122+
```graphql example
1123+
extend field User.name @deprecated(”Some reason”)
1124+
```
1125+
1126+
** Field Validation **
1127+
1128+
Field validation have the potential to be invalid if incorrectly defined.
1129+
1130+
1. The field must already be defined and a field for a Type
1131+
2. Any non-repeatable directives provided must not already apply to the previous
1132+
field.
1133+
3. Any interfaces provided must not be already implemented by the previous
1134+
field.
1135+
4. The resulting extended field must be a super-set of all interfaces it
1136+
implements.
1137+
11081138
## Interfaces
11091139

11101140
InterfaceTypeDefinition :
@@ -1358,6 +1388,34 @@ defined.
13581388
6. The resulting extended Interface type must be a super-set of all Interfaces
13591389
it implements.
13601390

1391+
#### Interface Field Extensions
1392+
1393+
InterfaceFieldExtension :
1394+
1395+
- extend interface MemberCoordinate Directives[const]?
1396+
1397+
Interface field extensions are used to represent an interface which has been
1398+
extended from some previous interface. For example this may be a GraphQL service
1399+
which is itself an extension of another GraphQL service.
1400+
1401+
In this example, the name field on the User type is deprecated for an interface.
1402+
1403+
```graphql example
1404+
extend interface User.name @deprecated("Some reason.")
1405+
```
1406+
1407+
** Field Validation **
1408+
1409+
Field validation have the potential to be invalid if incorrectly defined.
1410+
1411+
1. The field must already be defined and a field for a Type
1412+
2. Any non-repeatable directives provided must not already apply to the previous
1413+
field.
1414+
3. Any interfaces provided must not be already implemented by the previous
1415+
field.
1416+
4. The resulting extended field must be a super-set of all interfaces it
1417+
implements.
1418+
13611419
## Unions
13621420

13631421
UnionTypeDefinition : Description? union Name Directives[Const]?

0 commit comments

Comments
 (0)