Skip to content

Commit 0e85d0d

Browse files
committed
SDL Spec changes
This adds the recent changes to the SDL proposal.
1 parent f2c96b0 commit 0e85d0d

File tree

11 files changed

+434
-88
lines changed

11 files changed

+434
-88
lines changed

src/language/__tests__/schema-kitchen-sink.graphql

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ type AnnotatedObject @onObject(arg: "value") {
2626
annotatedField(arg: Type = "default" @onArg): Type @onField
2727
}
2828

29+
type UndefinedType
30+
31+
extend type Foo {
32+
seven(argument: [String]): Type
33+
}
34+
35+
extend type Foo @onType
36+
2937
interface Bar {
3038
one: Type
3139
four(argument: String = "string"): String
@@ -35,16 +43,32 @@ interface AnnotatedInterface @onInterface {
3543
annotatedField(arg: Type @onArg): Type @onField
3644
}
3745

46+
interface UndefinedInterface
47+
48+
extend interface Bar {
49+
two(argument: InputType!): Type
50+
}
51+
52+
extend interface Bar @onInterface
53+
3854
union Feed = Story | Article | Advert
3955

4056
union AnnotatedUnion @onUnion = A | B
4157

4258
union AnnotatedUnionTwo @onUnion = | A | B
4359

60+
union UndefinedUnion
61+
62+
extend union Feed = Photo | Video
63+
64+
extend union Feed @onUnion
65+
4466
scalar CustomScalar
4567

4668
scalar AnnotatedScalar @onScalar
4769

70+
extend scalar CustomScalar @onScalar
71+
4872
enum Site {
4973
DESKTOP
5074
MOBILE
@@ -55,20 +79,30 @@ enum AnnotatedEnum @onEnum {
5579
OTHER_VALUE
5680
}
5781

82+
enum UndefinedEnum
83+
84+
extend enum Site {
85+
VR
86+
}
87+
88+
extend enum Site @onEnum
89+
5890
input InputType {
5991
key: String!
6092
answer: Int = 42
6193
}
6294

63-
input AnnotatedInput @onInputObjectType {
95+
input AnnotatedInput @onInputObject {
6496
annotatedField: Type @onField
6597
}
6698

67-
extend type Foo {
68-
seven(argument: [String]): Type
99+
input UndefinedInput
100+
101+
extend input InputType {
102+
other: Float = 1.23e4
69103
}
70104

71-
extend type Foo @onType
105+
extend input InputType @onInputObject
72106

73107
directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
74108

src/language/__tests__/schema-printer-test.js

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ type AnnotatedObject @onObject(arg: "value") {
7070
annotatedField(arg: Type = "default" @onArg): Type @onField
7171
}
7272
73+
type UndefinedType
74+
75+
extend type Foo {
76+
seven(argument: [String]): Type
77+
}
78+
79+
extend type Foo @onType
80+
7381
interface Bar {
7482
one: Type
7583
four(argument: String = "string"): String
@@ -79,16 +87,32 @@ interface AnnotatedInterface @onInterface {
7987
annotatedField(arg: Type @onArg): Type @onField
8088
}
8189
90+
interface UndefinedInterface
91+
92+
extend interface Bar {
93+
two(argument: InputType!): Type
94+
}
95+
96+
extend interface Bar @onInterface
97+
8298
union Feed = Story | Article | Advert
8399
84100
union AnnotatedUnion @onUnion = A | B
85101
86102
union AnnotatedUnionTwo @onUnion = A | B
87103
104+
union UndefinedUnion
105+
106+
extend union Feed = Photo | Video
107+
108+
extend union Feed @onUnion
109+
88110
scalar CustomScalar
89111
90112
scalar AnnotatedScalar @onScalar
91113
114+
extend scalar CustomScalar @onScalar
115+
92116
enum Site {
93117
DESKTOP
94118
MOBILE
@@ -99,20 +123,30 @@ enum AnnotatedEnum @onEnum {
99123
OTHER_VALUE
100124
}
101125
126+
enum UndefinedEnum
127+
128+
extend enum Site {
129+
VR
130+
}
131+
132+
extend enum Site @onEnum
133+
102134
input InputType {
103135
key: String!
104136
answer: Int = 42
105137
}
106138
107-
input AnnotatedInput @onInputObjectType {
139+
input AnnotatedInput @onInputObject {
108140
annotatedField: Type @onField
109141
}
110142
111-
extend type Foo {
112-
seven(argument: [String]): Type
143+
input UndefinedInput
144+
145+
extend input InputType {
146+
other: Float = 1.23e4
113147
}
114148
115-
extend type Foo @onType
149+
extend input InputType @onInputObject
116150
117151
directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
118152

src/language/ast.js

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,12 @@ export type ASTNode =
151151
| EnumTypeDefinitionNode
152152
| EnumValueDefinitionNode
153153
| InputObjectTypeDefinitionNode
154+
| ScalarTypeExtensionNode
154155
| ObjectTypeExtensionNode
156+
| InterfaceTypeExtensionNode
157+
| UnionTypeExtensionNode
158+
| EnumTypeExtensionNode
159+
| InputObjectTypeExtensionNode
155160
| DirectiveDefinitionNode;
156161

157162
// Name
@@ -398,15 +403,15 @@ export type ObjectTypeDefinitionNode = {
398403
name: NameNode,
399404
interfaces?: ?Array<NamedTypeNode>,
400405
directives?: ?Array<DirectiveNode>,
401-
fields: Array<FieldDefinitionNode>,
406+
fields?: ?Array<FieldDefinitionNode>,
402407
};
403408

404409
export type FieldDefinitionNode = {
405410
kind: 'FieldDefinition',
406411
loc?: Location,
407412
description?: ?StringValueNode,
408413
name: NameNode,
409-
arguments: Array<InputValueDefinitionNode>,
414+
arguments?: ?Array<InputValueDefinitionNode>,
410415
type: TypeNode,
411416
directives?: ?Array<DirectiveNode>,
412417
};
@@ -427,7 +432,7 @@ export type InterfaceTypeDefinitionNode = {
427432
description?: ?StringValueNode,
428433
name: NameNode,
429434
directives?: ?Array<DirectiveNode>,
430-
fields: Array<FieldDefinitionNode>,
435+
fields?: ?Array<FieldDefinitionNode>,
431436
};
432437

433438
export type UnionTypeDefinitionNode = {
@@ -436,7 +441,7 @@ export type UnionTypeDefinitionNode = {
436441
description?: ?StringValueNode,
437442
name: NameNode,
438443
directives?: ?Array<DirectiveNode>,
439-
types: Array<NamedTypeNode>,
444+
types?: ?Array<NamedTypeNode>,
440445
};
441446

442447
export type EnumTypeDefinitionNode = {
@@ -445,7 +450,7 @@ export type EnumTypeDefinitionNode = {
445450
description?: ?StringValueNode,
446451
name: NameNode,
447452
directives?: ?Array<DirectiveNode>,
448-
values: Array<EnumValueDefinitionNode>,
453+
values?: ?Array<EnumValueDefinitionNode>,
449454
};
450455

451456
export type EnumValueDefinitionNode = {
@@ -462,12 +467,25 @@ export type InputObjectTypeDefinitionNode = {
462467
description?: ?StringValueNode,
463468
name: NameNode,
464469
directives?: ?Array<DirectiveNode>,
465-
fields: Array<InputValueDefinitionNode>,
470+
fields?: ?Array<InputValueDefinitionNode>,
466471
};
467472

468473
// Type Extensions
469474

470-
export type TypeExtensionNode = ObjectTypeExtensionNode;
475+
export type TypeExtensionNode =
476+
| ScalarTypeExtensionNode
477+
| ObjectTypeExtensionNode
478+
| InterfaceTypeExtensionNode
479+
| UnionTypeExtensionNode
480+
| EnumTypeExtensionNode
481+
| InputObjectTypeExtensionNode;
482+
483+
export type ScalarTypeExtensionNode = {
484+
kind: 'ScalarTypeExtension',
485+
loc?: Location,
486+
name: NameNode,
487+
directives?: ?Array<DirectiveNode>,
488+
};
471489

472490
export type ObjectTypeExtensionNode = {
473491
kind: 'ObjectTypeExtension',
@@ -478,6 +496,38 @@ export type ObjectTypeExtensionNode = {
478496
fields?: ?Array<FieldDefinitionNode>,
479497
};
480498

499+
export type InterfaceTypeExtensionNode = {
500+
kind: 'InterfaceTypeExtension',
501+
loc?: Location,
502+
name: NameNode,
503+
directives?: ?Array<DirectiveNode>,
504+
fields?: ?Array<FieldDefinitionNode>,
505+
};
506+
507+
export type UnionTypeExtensionNode = {
508+
kind: 'UnionTypeExtension',
509+
loc?: Location,
510+
name: NameNode,
511+
directives?: ?Array<DirectiveNode>,
512+
types?: ?Array<NamedTypeNode>,
513+
};
514+
515+
export type EnumTypeExtensionNode = {
516+
kind: 'EnumTypeExtension',
517+
loc?: Location,
518+
name: NameNode,
519+
directives?: ?Array<DirectiveNode>,
520+
values?: ?Array<EnumValueDefinitionNode>,
521+
};
522+
523+
export type InputObjectTypeExtensionNode = {
524+
kind: 'InputObjectTypeExtension',
525+
loc?: Location,
526+
name: NameNode,
527+
directives?: ?Array<DirectiveNode>,
528+
fields?: ?Array<InputValueDefinitionNode>,
529+
};
530+
481531
// Directive Definitions
482532

483533
export type DirectiveDefinitionNode = {

src/language/kinds.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ export const INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition';
6868

6969
// Type Extensions
7070

71+
export const SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension';
7172
export const OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension';
73+
export const INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension';
74+
export const UNION_TYPE_EXTENSION = 'UnionTypeExtension';
75+
export const ENUM_TYPE_EXTENSION = 'EnumTypeExtension';
76+
export const INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension';
7277

7378
// Directive Definitions
7479

0 commit comments

Comments
 (0)