Skip to content

Commit 0444c3e

Browse files
committed
Use & to separate implemented interfaces, simplify grammar definitions
1 parent aeada74 commit 0444c3e

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

spec/Appendix B -- Grammar Summary.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ ObjectTypeExtension :
224224
- extend type Name ImplementsInterfaces? Directives[Const]
225225
- extend type Name ImplementsInterfaces
226226

227-
ImplementsInterfaces : implements NamedType+
227+
ImplementsInterfaces :
228+
- implements `&`? NamedType
229+
- ImplementsInterfaces & NamedType
228230

229231
FieldsDefinition : { FieldDefinition+ }
230232

@@ -240,16 +242,14 @@ InterfaceTypeExtension :
240242
- extend interface Name Directives[Const]? FieldsDefinition
241243
- extend interface Name Directives[Const]
242244

243-
UnionTypeDefinition : Description? union Name Directives[Const]? MemberTypesDefinition?
245+
UnionTypeDefinition : Description? union Name Directives[Const]? UnionMemberTypes?
244246

245-
MemberTypesDefinition : = MemberTypes
246-
247-
MemberTypes :
248-
- `|`? NamedType
249-
- MemberTypes | NamedType
247+
UnionMemberTypes :
248+
- = `|`? NamedType
249+
- UnionMemberTypes | NamedType
250250

251251
UnionTypeExtension :
252-
- extend union Name Directives[Const]? MemberTypesDefinition
252+
- extend union Name Directives[Const]? UnionMemberTypes
253253
- extend union Name Directives[Const]
254254

255255
EnumTypeDefinition : Description? enum Name Directives[Const]? EnumValuesDefinition?

spec/Section 3 -- Type System.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,9 @@ Scalar type extensions have the potential to be invalid if incorrectly defined.
482482

483483
ObjectTypeDefinition : Description? type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
484484

485-
ImplementsInterfaces : Description? implements NamedType+
485+
ImplementsInterfaces :
486+
- implements `&`? NamedType
487+
- ImplementsInterfaces & NamedType
486488

487489
FieldsDefinition : { FieldDefinition+ }
488490

@@ -878,18 +880,26 @@ For example, an interface `NamedEntity` may describe a required field and types
878880
such as `Person` or `Business` may then implement this interface to guarantee
879881
this field will always exist.
880882

883+
Types may also implement multiple interfaces. For example, `Business` implements
884+
both the `NamedEntity` and `ValuedEntity` interfaces in the example below.
885+
881886
```graphql example
882887
interface NamedEntity {
883888
name: String
884889
}
885890

891+
interface ValuedEntity {
892+
value: Int
893+
}
894+
886895
type Person implements NamedEntity {
887896
name: String
888897
age: Int
889898
}
890899

891-
type Business implements NamedEntity {
900+
type Business implements NamedEntity & ValuedEntity {
892901
name: String
902+
value: Int
893903
employeeCount: Int
894904
}
895905
```
@@ -1026,12 +1036,10 @@ Interface type extensions have the potential to be invalid if incorrectly define
10261036

10271037
## Unions
10281038

1029-
UnionTypeDefinition : Description? union Name Directives[Const]? MemberTypesDefinition?
1030-
1031-
MemberTypesDefinition : = MemberTypes
1039+
UnionTypeDefinition : Description? union Name Directives[Const]? UnionMemberTypes?
10321040

1033-
MemberTypes :
1034-
- `|`? NamedType
1041+
UnionMemberTypes :
1042+
- = `|`? NamedType
10351043
- MemberTypes | NamedType
10361044

10371045
GraphQL Unions represent an object that could be one of a list of GraphQL
@@ -1127,7 +1135,7 @@ Union types have the potential to be invalid if incorrectly defined.
11271135
### Union Extensions
11281136

11291137
UnionTypeExtension :
1130-
- extend union Name Directives[Const]? MemberTypesDefinition
1138+
- extend union Name Directives[Const]? UnionMemberTypes
11311139
- extend union Name Directives[Const]
11321140

11331141
Union type extensions are used to represent a union type which has been

0 commit comments

Comments
 (0)