Skip to content

Commit f6b9556

Browse files
committed
Use & to separate implemented interfaces, simplify grammar definitions
1 parent 2647927 commit f6b9556

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

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

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

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

890-
type Business implements NamedEntity {
899+
type Business implements NamedEntity & ValuedEntity {
891900
name: String
901+
value: Int
892902
employeeCount: Int
893903
}
894904
```
@@ -1025,12 +1035,10 @@ Interface type extensions have the potential to be invalid if incorrectly define
10251035

10261036
## Unions
10271037

1028-
UnionTypeDefinition : Description? union Name Directives[Const]? MemberTypesDefinition?
1029-
1030-
MemberTypesDefinition : = MemberTypes
1038+
UnionTypeDefinition : Description? union Name Directives[Const]? UnionMemberTypes?
10311039

1032-
MemberTypes :
1033-
- `|`? NamedType
1040+
UnionMemberTypes :
1041+
- = `|`? NamedType
10341042
- MemberTypes | NamedType
10351043

10361044
GraphQL Unions represent an object that could be one of a list of GraphQL
@@ -1126,7 +1134,7 @@ Union types have the potential to be invalid if incorrectly defined.
11261134
### Union Extensions
11271135

11281136
UnionTypeExtension :
1129-
- extend union Name Directives[Const]? MemberTypesDefinition
1137+
- extend union Name Directives[Const]? UnionMemberTypes
11301138
- extend union Name Directives[Const]
11311139

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

0 commit comments

Comments
 (0)