Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions src/__tests__/starWarsIntrospectionTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 12 additions & 2 deletions src/__tests__/starWarsSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
},
})
Expand Down
1 change: 1 addition & 0 deletions src/type/definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down