diff --git a/src/__tests__/starWarsIntrospectionTests.js b/src/__tests__/starWarsIntrospectionTests.js index fc51362a2e..0d49ac7b0b 100644 --- a/src/__tests__/starWarsIntrospectionTests.js +++ b/src/__tests__/starWarsIntrospectionTests.js @@ -298,6 +298,83 @@ describe('Star Wars Introspection Tests', () => { return testQuery(query, expected); }); + it('Allows querying the schema for field args', () => { + var query = ` + query IntrospectionQueryTypeQuery { + __schema { + queryType { + fields { + name + args { + name + description + type { + name + kind + ofType { + name + kind + } + } + defaultValue + } + } + } + } + } + `; + var expected = { + __schema: { + queryType: { + fields: [ + { + name: 'hero', + args: [] + }, + { + name: 'human', + args: [ + { + name: 'id', + description: 'id of the human', + type: { + kind: 'NON_NULL', + name: null, + ofType: { + kind: 'SCALAR', + name: 'String' + } + }, + defaultValue: null + } + ] + }, + { + name: 'droid', + args: [ + { + name: 'id', + description: 'id of the droid', + type: { + kind: 'NON_NULL', + name: null, + ofType: { + kind: 'SCALAR', + name: 'String' + } + }, + defaultValue: null + } + ] + } + ] + } + } + }; + + return testQuery(query, expected); + }); + it('Allows querying the schema for documentation', () => { var query = ` query IntrospectionDroidDescriptionQuery { diff --git a/src/__tests__/starWarsSchema.js b/src/__tests__/starWarsSchema.js index cff4cab45f..2839747bfa 100644 --- a/src/__tests__/starWarsSchema.js +++ b/src/__tests__/starWarsSchema.js @@ -243,12 +243,22 @@ var queryType = new GraphQLObjectType({ }, human: { type: humanType, - args: {id: { name: 'id', type: new GraphQLNonNull(GraphQLString)}}, + args: { + id: { + description: 'id of the human', + type: new GraphQLNonNull(GraphQLString) + } + }, resolve: (root, {id}) => starWarsData.Humans[id], }, droid: { type: droidType, - args: {id: { name: 'id', type: new GraphQLNonNull(GraphQLString)}}, + args: { + id: { + description: 'id of the droid', + type: new GraphQLNonNull(GraphQLString) + } + }, resolve: (root, {id}) => starWarsData.Droids[id], }, }) diff --git a/src/type/definition.js b/src/type/definition.js index 874b146ff0..cf8933f69c 100644 --- a/src/type/definition.js +++ b/src/type/definition.js @@ -300,6 +300,7 @@ function defineFieldMap( ); return { name: argName, + description: arg.description === undefined ? null : arg.description, type: arg.type, defaultValue: arg.defaultValue === undefined ? null : arg.defaultValue };