@@ -49,105 +49,52 @@ import { extendSchema } from '../extendSchema';
49
49
import { buildSchema } from '../buildASTSchema' ;
50
50
51
51
// Test schema.
52
- const SomeScalarType = new GraphQLScalarType ( { name : 'SomeScalar' } ) ;
53
-
54
- const SomeInterfaceType = new GraphQLInterfaceType ( {
55
- name : 'SomeInterface' ,
56
- fields : ( ) => ( {
57
- name : { type : GraphQLString } ,
58
- some : { type : SomeInterfaceType } ,
59
- } ) ,
60
- } ) ;
61
-
62
- const FooType = new GraphQLObjectType ( {
63
- name : 'Foo' ,
64
- interfaces : [ SomeInterfaceType ] ,
65
- fields : ( ) => ( {
66
- name : { type : GraphQLString } ,
67
- some : { type : SomeInterfaceType } ,
68
- tree : { type : GraphQLNonNull ( GraphQLList ( FooType ) ) } ,
69
- } ) ,
70
- } ) ;
71
-
72
- const BarType = new GraphQLObjectType ( {
73
- name : 'Bar' ,
74
- interfaces : [ SomeInterfaceType ] ,
75
- fields : ( ) => ( {
76
- name : { type : GraphQLString } ,
77
- some : { type : SomeInterfaceType } ,
78
- foo : { type : FooType } ,
79
- } ) ,
80
- } ) ;
81
-
82
- const BizType = new GraphQLObjectType ( {
83
- name : 'Biz' ,
84
- fields : ( ) => ( {
85
- fizz : { type : GraphQLString } ,
86
- } ) ,
87
- } ) ;
88
-
89
- const SomeUnionType = new GraphQLUnionType ( {
90
- name : 'SomeUnion' ,
91
- types : [ FooType , BizType ] ,
92
- } ) ;
93
-
94
- const SomeEnumType = new GraphQLEnumType ( {
95
- name : 'SomeEnum' ,
96
- values : {
97
- ONE : { value : 1 } ,
98
- TWO : { value : 2 } ,
99
- } ,
100
- } ) ;
101
-
102
- const SomeInputType = new GraphQLInputObjectType ( {
103
- name : 'SomeInput' ,
104
- fields : ( ) => ( {
105
- fooArg : { type : GraphQLString } ,
106
- } ) ,
107
- } ) ;
108
-
109
- const FooDirective = new GraphQLDirective ( {
110
- name : 'foo' ,
111
- args : {
112
- input : { type : SomeInputType } ,
113
- } ,
114
- isRepeatable : true ,
115
- locations : [
116
- DirectiveLocation . SCHEMA ,
117
- DirectiveLocation . SCALAR ,
118
- DirectiveLocation . OBJECT ,
119
- DirectiveLocation . FIELD_DEFINITION ,
120
- DirectiveLocation . ARGUMENT_DEFINITION ,
121
- DirectiveLocation . INTERFACE ,
122
- DirectiveLocation . UNION ,
123
- DirectiveLocation . ENUM ,
124
- DirectiveLocation . ENUM_VALUE ,
125
- DirectiveLocation . INPUT_OBJECT ,
126
- DirectiveLocation . INPUT_FIELD_DEFINITION ,
127
- ] ,
128
- } ) ;
129
-
130
- const testSchema = new GraphQLSchema ( {
131
- query : new GraphQLObjectType ( {
132
- name : 'Query' ,
133
- fields : ( ) => ( {
134
- foo : { type : FooType } ,
135
- someScalar : { type : SomeScalarType } ,
136
- someUnion : { type : SomeUnionType } ,
137
- someEnum : { type : SomeEnumType } ,
138
- someInterface : {
139
- args : { id : { type : GraphQLNonNull ( GraphQLID ) } } ,
140
- type : SomeInterfaceType ,
141
- } ,
142
- someInput : {
143
- args : { input : { type : SomeInputType } } ,
144
- type : GraphQLString ,
145
- } ,
146
- } ) ,
147
- } ) ,
148
- types : [ FooType , BarType ] ,
149
- directives : specifiedDirectives . concat ( [ FooDirective ] ) ,
150
- } ) ;
52
+ const testSchema = buildSchema ( `
53
+ scalar SomeScalar
54
+
55
+ interface SomeInterface {
56
+ name: String
57
+ some: SomeInterface
58
+ }
59
+
60
+ type Foo implements SomeInterface {
61
+ name: String
62
+ some: SomeInterface
63
+ tree: [Foo]!
64
+ }
65
+
66
+ type Bar implements SomeInterface {
67
+ name: String
68
+ some: SomeInterface
69
+ foo: Foo
70
+ }
71
+
72
+ type Biz {
73
+ fizz: String
74
+ }
75
+
76
+ union SomeUnion = Foo | Biz
77
+
78
+ enum SomeEnum {
79
+ ONE
80
+ TWO
81
+ }
82
+
83
+ input SomeInput {
84
+ fooArg: String
85
+ }
86
+
87
+ directive @foo(input: SomeInput) repeatable on SCHEMA | SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
88
+
89
+ type Query {
90
+ foo: Foo
91
+ someScalar: SomeScalar
92
+ someUnion: SomeUnion
93
+ someEnum: SomeEnum
94
+ someInterface(id: ID!): SomeInterface
95
+ someInput(input: SomeInput): String
96
+ }
97
+ ` ) ;
151
98
152
99
function extendTestSchema ( sdl , options ) {
153
100
const originalPrint = printSchema ( testSchema ) ;
@@ -1203,10 +1150,10 @@ describe('extendSchema', () => {
1203
1150
} ) ;
1204
1151
1205
1152
it ( 'adds schema definition missing in the original schema' , ( ) => {
1206
- let schema = new GraphQLSchema ( {
1207
- directives : [ FooDirective ] ,
1208
- types : [ FooType ] ,
1209
- } ) ;
1153
+ let schema = buildSchema ( `
1154
+ directive @foo on SCHEMA
1155
+ type Foo
1156
+ ` ) ;
1210
1157
expect ( schema . getQueryType ( ) ) . to . equal ( undefined ) ;
1211
1158
1212
1159
const extensionSDL = dedent `
0 commit comments