File tree 1 file changed +22
-36
lines changed 1 file changed +22
-36
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,15 @@ export interface IntrospectionOptions {
38
38
* Default: false
39
39
*/
40
40
oneOf ?: boolean ;
41
+
42
+ /**
43
+ * How deep to recurse into nested types. Larger values will result in more
44
+ * accurate results, but have a higher load. Some servers might restrict the
45
+ * maximum query depth. If thats the case, try decreasing this value.
46
+ *
47
+ * Default: 9
48
+ */
49
+ typeDepth ?: number ;
41
50
}
42
51
43
52
/**
@@ -52,6 +61,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string {
52
61
schemaDescription : false ,
53
62
inputValueDeprecation : false ,
54
63
oneOf : false ,
64
+ typeDepth : 9 ,
55
65
...options ,
56
66
} ;
57
67
@@ -70,6 +80,17 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string {
70
80
return optionsWithDefault . inputValueDeprecation ? str : '' ;
71
81
}
72
82
const oneOf = optionsWithDefault . oneOf ? 'isOneOf' : '' ;
83
+ function ofType ( level = 9 ) : string {
84
+ if ( level <= 0 ) {
85
+ return '' ;
86
+ }
87
+ return `
88
+ ofType {
89
+ name
90
+ kind
91
+ ${ ofType ( level - 1 ) }
92
+ }` ;
93
+ }
73
94
74
95
return `
75
96
query IntrospectionQuery {
@@ -140,42 +161,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string {
140
161
fragment TypeRef on __Type {
141
162
kind
142
163
name
143
- ofType {
144
- kind
145
- name
146
- ofType {
147
- kind
148
- name
149
- ofType {
150
- kind
151
- name
152
- ofType {
153
- kind
154
- name
155
- ofType {
156
- kind
157
- name
158
- ofType {
159
- kind
160
- name
161
- ofType {
162
- kind
163
- name
164
- ofType {
165
- kind
166
- name
167
- ofType {
168
- kind
169
- name
170
- }
171
- }
172
- }
173
- }
174
- }
175
- }
176
- }
177
- }
178
- }
164
+ ${ ofType ( optionsWithDefault . typeDepth ) }
179
165
}
180
166
` ;
181
167
}
You can’t perform that action at this time.
0 commit comments