Skip to content

Commit 7fea276

Browse files
author
Michael Solomon
committed
Deepen introspection query
1 parent dd02973 commit 7fea276

File tree

2 files changed

+47
-8
lines changed

2 files changed

+47
-8
lines changed

src/utilities/__tests__/buildClientSchema-test.js

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('Type System: build schema from introspection', () => {
6363
await testSchema(schema);
6464
});
6565

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

727727
});
728728

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

731-
it('fails on very deep lists', async () => {
731+
it('fails on very deep (> 7 levels) lists', async () => {
732732
const schema = new GraphQLSchema({
733733
query: new GraphQLObjectType({
734734
name: 'Query',
735735
fields: {
736736
foo: {
737737
type: new GraphQLList(new GraphQLList(new GraphQLList(
738-
new GraphQLList(GraphQLString)
739-
)))
738+
new GraphQLList(new GraphQLList(new GraphQLList(
739+
new GraphQLList(new GraphQLNonNull(GraphQLString))
740+
))))))
740741
}
741742
}
742743
})
@@ -748,15 +749,16 @@ describe('Type System: build schema from introspection', () => {
748749
).to.throw('Decorated type deeper than introspection query.');
749750
});
750751

751-
it('fails on a deep non-null', async () => {
752+
it('fails on a very deep (> 7 levels) non-null', async () => {
752753
const schema = new GraphQLSchema({
753754
query: new GraphQLObjectType({
754755
name: 'Query',
755756
fields: {
756757
foo: {
757758
type: new GraphQLList(new GraphQLList(new GraphQLList(
758-
new GraphQLNonNull(GraphQLString)
759-
)))
759+
new GraphQLList(new GraphQLList(new GraphQLList(
760+
new GraphQLList(new GraphQLNonNull(GraphQLString))
761+
))))))
760762
}
761763
}
762764
})
@@ -768,6 +770,27 @@ describe('Type System: build schema from introspection', () => {
768770
).to.throw('Decorated type deeper than introspection query.');
769771
});
770772

773+
it('succeeds on deep (<= 7 levels) types', async () => {
774+
const schema = new GraphQLSchema({
775+
query: new GraphQLObjectType({
776+
name: 'Query',
777+
fields: {
778+
foo: {
779+
// e.g., fully non-null 3D matrix
780+
type: new GraphQLNonNull(new GraphQLList(
781+
new GraphQLNonNull(new GraphQLList(
782+
new GraphQLNonNull(new GraphQLList(
783+
new GraphQLNonNull(GraphQLString)
784+
))))))
785+
}
786+
}
787+
})
788+
});
789+
790+
const introspection = await graphql(schema, introspectionQuery);
791+
buildClientSchema(introspection.data);
792+
});
793+
771794
});
772795

773796
});

src/utilities/introspectionQuery.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@ export const introspectionQuery = `
8383
ofType {
8484
kind
8585
name
86+
ofType {
87+
kind
88+
name
89+
ofType {
90+
kind
91+
name
92+
ofType {
93+
kind
94+
name
95+
ofType {
96+
kind
97+
name
98+
}
99+
}
100+
}
101+
}
86102
}
87103
}
88104
}

0 commit comments

Comments
 (0)