@@ -16,6 +16,10 @@ export type IntrospectionOptions = {|
1616 // Whether to include `description` field on schema.
1717 // Default: false
1818 schemaDescription ? : boolean ,
19+
20+ // Whether target GraphQL server support deprecation of input values.
21+ // Default: false
22+ inputValueDeprecation ? : boolean ,
1923| } ;
2024
2125export function getIntrospectionQuery ( options ?: IntrospectionOptions ) : string {
@@ -24,6 +28,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string {
2428 specifiedByUrl : false ,
2529 directiveIsRepeatable : false ,
2630 schemaDescription : false ,
31+ inputValueDeprecation : false ,
2732 ...options ,
2833 } ;
2934
@@ -38,6 +43,10 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string {
3843 ? descriptions
3944 : '' ;
4045
46+ function inputDeprecation ( str ) {
47+ return optionsWithDefault . inputValueDeprecation ? str : '' ;
48+ }
49+
4150 return `
4251 query IntrospectionQuery {
4352 __schema {
@@ -53,7 +62,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string {
5362 ${ descriptions }
5463 ${ directiveIsRepeatable }
5564 locations
56- args {
65+ args${ inputDeprecation ( '(includeDeprecated: true)' ) } {
5766 ...InputValue
5867 }
5968 }
@@ -68,7 +77,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string {
6877 fields(includeDeprecated: true) {
6978 name
7079 ${ descriptions }
71- args {
80+ args${ inputDeprecation ( '(includeDeprecated: true)' ) } {
7281 ...InputValue
7382 }
7483 type {
@@ -77,7 +86,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string {
7786 isDeprecated
7887 deprecationReason
7988 }
80- inputFields {
89+ inputFields${ inputDeprecation ( '(includeDeprecated: true)' ) } {
8190 ...InputValue
8291 }
8392 interfaces {
@@ -99,6 +108,8 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string {
99108 ${ descriptions }
100109 type { ...TypeRef }
101110 defaultValue
111+ ${ inputDeprecation ( 'isDeprecated' ) }
112+ ${ inputDeprecation ( 'deprecationReason' ) }
102113 }
103114
104115 fragment TypeRef on __Type {
@@ -280,6 +291,8 @@ export type IntrospectionInputValue = {|
280291 + description ?: ?string ,
281292 + type : IntrospectionInputTypeRef ,
282293 + defaultValue : ?string ,
294+ + isDeprecated ?: boolean ,
295+ + deprecationReason ?: ?string ,
283296| } ;
284297
285298export type IntrospectionEnumValue = { |
0 commit comments