Skip to content

Commit

Permalink
Deepen introspection query (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Solomon authored and leebyron committed Apr 25, 2016
1 parent cbded82 commit 0b72e70
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 8 deletions.
39 changes: 31 additions & 8 deletions src/utilities/__tests__/buildClientSchema-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('Type System: build schema from introspection', () => {
await testSchema(schema);
});

it('builds a simple schema with both operation types', async () => {
it('builds a simple schema with all operation types', async () => {
const queryType = new GraphQLObjectType({
name: 'QueryType',
description: 'This is a simple query type',
Expand Down Expand Up @@ -726,17 +726,18 @@ describe('Type System: build schema from introspection', () => {

});

describe('KP: very deep decorators are not supported', () => {
describe('very deep decorators are not supported', () => {

it('fails on very deep lists', async () => {
it('fails on very deep (> 7 levels) lists', async () => {
const schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'Query',
fields: {
foo: {
type: new GraphQLList(new GraphQLList(new GraphQLList(
new GraphQLList(GraphQLString)
)))
new GraphQLList(new GraphQLList(new GraphQLList(
new GraphQLList(new GraphQLNonNull(GraphQLString))
))))))
}
}
})
Expand All @@ -748,15 +749,16 @@ describe('Type System: build schema from introspection', () => {
).to.throw('Decorated type deeper than introspection query.');
});

it('fails on a deep non-null', async () => {
it('fails on a very deep (> 7 levels) non-null', async () => {
const schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'Query',
fields: {
foo: {
type: new GraphQLList(new GraphQLList(new GraphQLList(
new GraphQLNonNull(GraphQLString)
)))
new GraphQLList(new GraphQLList(new GraphQLList(
new GraphQLList(new GraphQLNonNull(GraphQLString))
))))))
}
}
})
Expand All @@ -768,6 +770,27 @@ describe('Type System: build schema from introspection', () => {
).to.throw('Decorated type deeper than introspection query.');
});

it('succeeds on deep (<= 7 levels) types', async () => {
const schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'Query',
fields: {
foo: {
// e.g., fully non-null 3D matrix
type: new GraphQLNonNull(new GraphQLList(
new GraphQLNonNull(new GraphQLList(
new GraphQLNonNull(new GraphQLList(
new GraphQLNonNull(GraphQLString)
))))))
}
}
})
});

const introspection = await graphql(schema, introspectionQuery);
buildClientSchema(introspection.data);
});

});

});
16 changes: 16 additions & 0 deletions src/utilities/introspectionQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,22 @@ export const introspectionQuery = `
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
}
}
}
}
}
}
}
Expand Down

0 comments on commit 0b72e70

Please sign in to comment.