@@ -154,21 +154,17 @@ extend type Hello {
154
154
kind : 'Document' ,
155
155
definitions : [
156
156
{
157
- kind : 'TypeExtensionDefinition' ,
158
- definition : {
159
- kind : 'ObjectTypeDefinition' ,
160
- name : nameNode ( 'Hello' , { start : 13 , end : 18 } ) ,
161
- interfaces : [ ] ,
162
- directives : [ ] ,
163
- fields : [
164
- fieldNode (
165
- nameNode ( 'world' , { start : 23 , end : 28 } ) ,
166
- typeNode ( 'String' , { start : 30 , end : 36 } ) ,
167
- { start : 23 , end : 36 }
168
- )
169
- ] ,
170
- loc : { start : 8 , end : 38 } ,
171
- } ,
157
+ kind : 'ObjectTypeExtension' ,
158
+ name : nameNode ( 'Hello' , { start : 13 , end : 18 } ) ,
159
+ interfaces : [ ] ,
160
+ directives : [ ] ,
161
+ fields : [
162
+ fieldNode (
163
+ nameNode ( 'world' , { start : 23 , end : 28 } ) ,
164
+ typeNode ( 'String' , { start : 30 , end : 36 } ) ,
165
+ { start : 23 , end : 36 }
166
+ )
167
+ ] ,
172
168
loc : { start : 1 , end : 38 } ,
173
169
}
174
170
] ,
@@ -177,13 +173,39 @@ extend type Hello {
177
173
expect ( printJson ( doc ) ) . to . equal ( printJson ( expected ) ) ;
178
174
} ) ;
179
175
176
+ it ( 'Extension without fields' , ( ) => {
177
+ const body = 'extend type Hello implements Greeting' ;
178
+ const doc = parse ( body ) ;
179
+ const expected = {
180
+ kind : 'Document' ,
181
+ definitions : [
182
+ {
183
+ kind : 'ObjectTypeExtension' ,
184
+ name : nameNode ( 'Hello' , { start : 12 , end : 17 } ) ,
185
+ interfaces : [ typeNode ( 'Greeting' , { start : 29 , end : 37 } ) ] ,
186
+ directives : [ ] ,
187
+ fields : [ ] ,
188
+ loc : { start : 0 , end : 37 } ,
189
+ }
190
+ ] ,
191
+ loc : { start : 0 , end : 37 }
192
+ } ;
193
+ expect ( printJson ( doc ) ) . to . equal ( printJson ( expected ) ) ;
194
+ } ) ;
195
+
180
196
it ( 'Extension do not include descriptions' , ( ) => {
181
197
expect ( ( ) => parse ( `
182
198
"Description"
183
199
extend type Hello {
184
200
world: String
185
201
}
186
- ` ) ) . to . throw ( 'Syntax Error GraphQL request (2:7)' ) ;
202
+ ` ) ) . to . throw ( 'Syntax Error GraphQL request (3:7)' ) ;
203
+
204
+ expect ( ( ) => parse ( `
205
+ extend "Description" type Hello {
206
+ world: String
207
+ }
208
+ ` ) ) . to . throw ( 'Syntax Error GraphQL request (2:14)' ) ;
187
209
} ) ;
188
210
189
211
it ( 'Simple non-null type' , ( ) => {
@@ -219,9 +241,8 @@ type Hello {
219
241
expect ( printJson ( doc ) ) . to . equal ( printJson ( expected ) ) ;
220
242
} ) ;
221
243
222
-
223
244
it ( 'Simple type inheriting interface' , ( ) => {
224
- const body = 'type Hello implements World { }' ;
245
+ const body = 'type Hello implements World { field: String }' ;
225
246
const doc = parse ( body ) ;
226
247
const expected = {
227
248
kind : 'Document' ,
@@ -231,17 +252,23 @@ type Hello {
231
252
name : nameNode ( 'Hello' , { start : 5 , end : 10 } ) ,
232
253
interfaces : [ typeNode ( 'World' , { start : 22 , end : 27 } ) ] ,
233
254
directives : [ ] ,
234
- fields : [ ] ,
235
- loc : { start : 0 , end : 31 } ,
255
+ fields : [
256
+ fieldNode (
257
+ nameNode ( 'field' , { start : 30 , end : 35 } ) ,
258
+ typeNode ( 'String' , { start : 37 , end : 43 } ) ,
259
+ { start : 30 , end : 43 }
260
+ )
261
+ ] ,
262
+ loc : { start : 0 , end : 45 } ,
236
263
}
237
264
] ,
238
- loc : { start : 0 , end : 31 } ,
265
+ loc : { start : 0 , end : 45 } ,
239
266
} ;
240
267
expect ( printJson ( doc ) ) . to . equal ( printJson ( expected ) ) ;
241
268
} ) ;
242
269
243
270
it ( 'Simple type inheriting multiple interfaces' , ( ) => {
244
- const body = 'type Hello implements Wo, rld { }' ;
271
+ const body = 'type Hello implements Wo, rld { field: String }' ;
245
272
const doc = parse ( body ) ;
246
273
const expected = {
247
274
kind : 'Document' ,
@@ -254,11 +281,17 @@ type Hello {
254
281
typeNode ( 'rld' , { start : 26 , end : 29 } )
255
282
] ,
256
283
directives : [ ] ,
257
- fields : [ ] ,
258
- loc : { start : 0 , end : 33 } ,
284
+ fields : [
285
+ fieldNode (
286
+ nameNode ( 'field' , { start : 32 , end : 37 } ) ,
287
+ typeNode ( 'String' , { start : 39 , end : 45 } ) ,
288
+ { start : 32 , end : 45 }
289
+ )
290
+ ] ,
291
+ loc : { start : 0 , end : 47 } ,
259
292
}
260
293
] ,
261
- loc : { start : 0 , end : 33 } ,
294
+ loc : { start : 0 , end : 47 } ,
262
295
} ;
263
296
expect ( printJson ( doc ) ) . to . equal ( printJson ( expected ) ) ;
264
297
} ) ;
0 commit comments