Skip to content

Commit a52ecc5

Browse files
committed
RFC: SchemaExtension
This adds new grammar to the GraphQL SDL: ```graphql extend schema { mutation: MutationType } ``` This feels like the missing piece of the type system extension framework. In addition to extending types in a type system, the top level schema should be extendable as well.
1 parent 1d56b88 commit a52ecc5

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

spec/Appendix B -- Grammar Summary.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,19 @@ Directive[Const] : @ Name Arguments[?Const]?
187187
TypeSystemDefinition :
188188
- SchemaDefinition
189189
- TypeDefinition
190-
- TypeExtension
191190
- DirectiveDefinition
191+
- TypeSystemExtension
192+
193+
TypeSystemExtension :
194+
- SchemaExtension
195+
- TypeExtension
192196

193197
SchemaDefinition : schema Directives[Const]? { OperationTypeDefinition+ }
194198

199+
SchemaExtension :
200+
- extend schema Directives[Const]? { OperationTypeDefinition+ }
201+
- extend schema Directives[Const]
202+
195203
OperationTypeDefinition : OperationType : NamedType
196204

197205
Description : StringValue

spec/Section 3 -- Type System.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ are valid.
88
TypeSystemDefinition :
99
- SchemaDefinition
1010
- TypeDefinition
11-
- TypeExtension
1211
- DirectiveDefinition
12+
- TypeSystemExtension
1313

1414
The GraphQL language includes an
1515
[IDL](https://en.wikipedia.org/wiki/Interface_description_language) used to
@@ -27,6 +27,18 @@ Note: The type system definition language is used throughout the remainder of
2727
this specification document when illustrating example type systems.
2828

2929

30+
## Type System Extensions
31+
32+
TypeSystemExtension :
33+
- SchemaExtension
34+
- TypeExtension
35+
36+
Type system extensions are used to represent a GraphQL type system which has been
37+
extended from some original type system. For example, this might be used by a
38+
local service to represent data a GraphQL client only accesses locally, or by a
39+
GraphQL service which is itself an extension of another GraphQL service.
40+
41+
3042
## Schema
3143

3244
SchemaDefinition : schema Directives[Const]? { RootOperationTypeDefinition+ }
@@ -139,6 +151,17 @@ type Query {
139151
}
140152
```
141153

154+
### Schema Extension
155+
156+
SchemaExtension :
157+
- extend schema Directives[Const]? { OperationTypeDefinition+ }
158+
- extend schema Directives[Const]
159+
160+
Schema extensions are used to represent a schema which has been extended from
161+
some original schema type. For example, this might be used by a GraphQL service
162+
which adds additional operation types, or additional directives to an existing
163+
schema.
164+
142165

143166
## Descriptions
144167

@@ -261,10 +284,9 @@ TypeExtension :
261284
- EnumTypeExtension
262285
- InputObjectTypeExtension
263286

264-
Type extensions are used to represent a GraphQL type system which has been
265-
extended from some original type system. For example, this might be used by a
266-
local service to represent data a GraphQL client only accesses locally, or by a
267-
GraphQL service which is itself an extension of another GraphQL service.
287+
Type extensions are used to represent a GraphQL type which has been extended
288+
from some original type. For example, this might be used by a local service to
289+
represent additional fields a GraphQL client only accesses locally.
268290

269291

270292
## Scalars

0 commit comments

Comments
 (0)