Skip to content

Commit 32b55ed

Browse files
committed
Use & to separate implemented interfaces, simplify grammar definitions
1 parent af44f46 commit 32b55ed

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

spec/Appendix B -- Grammar Summary.md

+8-8
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

+16-8
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,9 @@ Scalar type extensions have the potential to be invalid if incorrectly defined.
480480

481481
ObjectTypeDefinition : Description? type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
482482

483-
ImplementsInterfaces : Description? implements NamedType+
483+
ImplementsInterfaces :
484+
- implements `&`? NamedType
485+
- ImplementsInterfaces & NamedType
484486

485487
FieldsDefinition : { FieldDefinition+ }
486488

@@ -875,18 +877,26 @@ For example, an interface `NamedEntity` may describe a required field and types
875877
such as `Person` or `Business` may then implement this interface to guarantee
876878
this field will always exist.
877879

880+
Types may also implement multiple interfaces. For example, `Business` implements
881+
both the `NamedEntity` and `ValuedEntity` interfaces in the example below.
882+
878883
```graphql example
879884
interface NamedEntity {
880885
name: String
881886
}
882887

888+
interface ValuedEntity {
889+
value: Int
890+
}
891+
883892
type Person implements NamedEntity {
884893
name: String
885894
age: Int
886895
}
887896

888-
type Business implements NamedEntity {
897+
type Business implements NamedEntity & ValuedEntity {
889898
name: String
899+
value: Int
890900
employeeCount: Int
891901
}
892902
```
@@ -1023,12 +1033,10 @@ Interface type extensions have the potential to be invalid if incorrectly define
10231033

10241034
## Unions
10251035

1026-
UnionTypeDefinition : Description? union Name Directives[Const]? MemberTypesDefinition?
1027-
1028-
MemberTypesDefinition : = MemberTypes
1036+
UnionTypeDefinition : Description? union Name Directives[Const]? UnionMemberTypes?
10291037

1030-
MemberTypes :
1031-
- `|`? NamedType
1038+
UnionMemberTypes :
1039+
- = `|`? NamedType
10321040
- MemberTypes | NamedType
10331041

10341042
GraphQL Unions represent an object that could be one of a list of GraphQL
@@ -1124,7 +1132,7 @@ Union types have the potential to be invalid if incorrectly defined.
11241132
### Union Extensions
11251133

11261134
UnionTypeExtension :
1127-
- extend union Name Directives[Const]? MemberTypesDefinition
1135+
- extend union Name Directives[Const]? UnionMemberTypes
11281136
- extend union Name Directives[Const]
11291137

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

0 commit comments

Comments
 (0)