-
Notifications
You must be signed in to change notification settings - Fork 2k
Allow configuration of the ofType
introspection depth
#4317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 16.x.x
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,15 @@ | |
* Default: false | ||
*/ | ||
oneOf?: boolean; | ||
|
||
/** | ||
* How deep to recurse into nested types. Larger values will result in more | ||
* accurate results, but have a higher load. Some servers might restrict the | ||
* maximum query depth. If thats the case, try decreasing this value. | ||
* | ||
* Default: 9 | ||
*/ | ||
typeDepth?: number; | ||
} | ||
|
||
/** | ||
|
@@ -52,6 +61,7 @@ | |
schemaDescription: false, | ||
inputValueDeprecation: false, | ||
oneOf: false, | ||
typeDepth: 9, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so this default is a breaking change. If we want this to land in v16 then we should do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is that a breaking change? The behaviour is exactly the same as before. Infinity would lead to an infinite recursive loop. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @saihaj I think you may have misunderstood which depth this relates to - it's the |
||
...options, | ||
}; | ||
|
||
|
@@ -70,6 +80,19 @@ | |
return optionsWithDefault.inputValueDeprecation ? str : ''; | ||
} | ||
const oneOf = optionsWithDefault.oneOf ? 'isOneOf' : ''; | ||
function ofType(level: number, indent: string): string { | ||
if (level <= 0) { | ||
return ''; | ||
} | ||
if (level > 100) { | ||
throw new Error("Please set typeDepth to a reasonable value; the default is 9."); | ||
Nols1000 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
return ` | ||
${indent}ofType { | ||
${indent} name | ||
${indent} kind${ofType(level - 1, indent + " ")} | ||
Nols1000 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
${indent}}`; | ||
} | ||
|
||
return ` | ||
query IntrospectionQuery { | ||
|
@@ -139,43 +162,7 @@ | |
|
||
fragment TypeRef on __Type { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
name${ofType(optionsWithDefault.typeDepth ?? 9, " ")} | ||
Nols1000 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
`; | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.