Skip to content

Commit 38f638c

Browse files
committed
Merge pull request #37 from albertstill/args-description-fix
Add missing `description` to field args
2 parents fe2ee65 + 1753f98 commit 38f638c

File tree

3 files changed

+90
-2
lines changed

3 files changed

+90
-2
lines changed

src/__tests__/starWarsIntrospectionTests.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,83 @@ describe('Star Wars Introspection Tests', () => {
298298
return testQuery(query, expected);
299299
});
300300

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+
301378
it('Allows querying the schema for documentation', () => {
302379
var query = `
303380
query IntrospectionDroidDescriptionQuery {

src/__tests__/starWarsSchema.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,22 @@ var queryType = new GraphQLObjectType({
243243
},
244244
human: {
245245
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+
},
247252
resolve: (root, {id}) => starWarsData.Humans[id],
248253
},
249254
droid: {
250255
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+
},
252262
resolve: (root, {id}) => starWarsData.Droids[id],
253263
},
254264
})

src/type/definition.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ function defineFieldMap(
300300
);
301301
return {
302302
name: argName,
303+
description: arg.description === undefined ? null : arg.description,
303304
type: arg.type,
304305
defaultValue: arg.defaultValue === undefined ? null : arg.defaultValue
305306
};

0 commit comments

Comments
 (0)