File tree Expand file tree Collapse file tree 3 files changed +90
-2
lines changed Expand file tree Collapse file tree 3 files changed +90
-2
lines changed Original file line number Diff line number Diff line change @@ -298,6 +298,83 @@ describe('Star Wars Introspection Tests', () => {
298
298
return testQuery ( query , expected ) ;
299
299
} ) ;
300
300
301
+ it ( 'Allows querying the schema for field args' , ( ) => {
302
+ var query = `
303
+ query IntrospectionQueryTypeQuery {
304
+ __schema {
305
+ queryType {
306
+ fields {
307
+ name
308
+ args {
309
+ name
310
+ description
311
+ type {
312
+ name
313
+ kind
314
+ ofType {
315
+ name
316
+ kind
317
+ }
318
+ }
319
+ defaultValue
320
+ }
321
+ }
322
+ }
323
+ }
324
+ }
325
+ ` ;
326
+ var expected = {
327
+ __schema : {
328
+ queryType : {
329
+ fields : [
330
+ {
331
+ name : 'hero' ,
332
+ args : [ ]
333
+ } ,
334
+ {
335
+ name : 'human' ,
336
+ args : [
337
+ {
338
+ name : 'id' ,
339
+ description : 'id of the human' ,
340
+ type : {
341
+ kind : 'NON_NULL' ,
342
+ name : null ,
343
+ ofType : {
344
+ kind : 'SCALAR' ,
345
+ name : 'String'
346
+ }
347
+ } ,
348
+ defaultValue : null
349
+ }
350
+ ]
351
+ } ,
352
+ {
353
+ name : 'droid' ,
354
+ args : [
355
+ {
356
+ name : 'id' ,
357
+ description : 'id of the droid' ,
358
+ type : {
359
+ kind : 'NON_NULL' ,
360
+ name : null ,
361
+ ofType : {
362
+ kind : 'SCALAR' ,
363
+ name : 'String'
364
+ }
365
+ } ,
366
+ defaultValue : null
367
+ }
368
+ ]
369
+ }
370
+ ]
371
+ }
372
+ }
373
+ } ;
374
+
375
+ return testQuery ( query , expected ) ;
376
+ } ) ;
377
+
301
378
it ( 'Allows querying the schema for documentation' , ( ) => {
302
379
var query = `
303
380
query IntrospectionDroidDescriptionQuery {
Original file line number Diff line number Diff line change @@ -243,12 +243,22 @@ var queryType = new GraphQLObjectType({
243
243
} ,
244
244
human : {
245
245
type : humanType ,
246
- args : { id : { name : 'id' , type : new GraphQLNonNull ( GraphQLString ) } } ,
246
+ args : {
247
+ id : {
248
+ description : 'id of the human' ,
249
+ type : new GraphQLNonNull ( GraphQLString )
250
+ }
251
+ } ,
247
252
resolve : ( root , { id} ) => starWarsData . Humans [ id ] ,
248
253
} ,
249
254
droid : {
250
255
type : droidType ,
251
- args : { id : { name : 'id' , type : new GraphQLNonNull ( GraphQLString ) } } ,
256
+ args : {
257
+ id : {
258
+ description : 'id of the droid' ,
259
+ type : new GraphQLNonNull ( GraphQLString )
260
+ }
261
+ } ,
252
262
resolve : ( root , { id} ) => starWarsData . Droids [ id ] ,
253
263
} ,
254
264
} )
Original file line number Diff line number Diff line change @@ -300,6 +300,7 @@ function defineFieldMap(
300
300
) ;
301
301
return {
302
302
name : argName ,
303
+ description : arg . description === undefined ? null : arg . description ,
303
304
type : arg . type ,
304
305
defaultValue : arg . defaultValue === undefined ? null : arg . defaultValue
305
306
} ;
You can’t perform that action at this time.
0 commit comments