3030 * @phpstan-type IntrospectionOptions array{
3131 * descriptions?: bool,
3232 * directiveIsRepeatable?: bool,
33+ * includeDeprecated?: bool,
3334 * schemaDescription?: bool,
3435 * typeIsOneOf?: bool,
3536 * }
4142 * - directiveIsRepeatable
4243 * Include field `isRepeatable` for directives?
4344 * Default: false
45+ * - includeDeprecated
46+ * Include deprecated fields/args/enum values/input fields and related indicators
47+ * (isDeprecated/deprecationReason) in the introspection query
48+ * Default: true
49+ *
50+ * @see https://graphql-ruby.org/api-doc/1.12.1/GraphQL/Introspection.html
4451 * - typeIsOneOf
4552 * Include field `isOneOf` for types?
4653 * Default: false
47- *
4854 * @see \GraphQL\Tests\Type\IntrospectionTest
4955 */
5056class Introspection
@@ -86,6 +92,7 @@ public static function getIntrospectionQuery(array $options = []): string
8692 $ optionsWithDefaults = array_merge ([
8793 'descriptions ' => true ,
8894 'directiveIsRepeatable ' => false ,
95+ 'includeDeprecated ' => true ,
8996 'schemaDescription ' => false ,
9097 'typeIsOneOf ' => false ,
9198 ], $ options );
@@ -102,6 +109,13 @@ public static function getIntrospectionQuery(array $options = []): string
102109 $ typeIsOneOf = $ optionsWithDefaults ['typeIsOneOf ' ]
103110 ? 'isOneOf '
104111 : '' ;
112+ $ includeDeprecated = $ optionsWithDefaults ['includeDeprecated ' ];
113+ $ includeDeprecatedArg = $ includeDeprecated
114+ ? '(includeDeprecated: true) '
115+ : '' ;
116+ $ deprecationIndicators = $ includeDeprecated
117+ ? " isDeprecated \n deprecationReason "
118+ : '' ;
105119
106120 return <<<GRAPHQL
107121 query IntrospectionQuery {
@@ -116,7 +130,7 @@ public static function getIntrospectionQuery(array $options = []): string
116130 directives {
117131 name
118132 {$ descriptions }
119- args(includeDeprecated: true) {
133+ args { $ includeDeprecatedArg } {
120134 ...InputValue
121135 }
122136 {$ directiveIsRepeatable }
@@ -130,29 +144,27 @@ public static function getIntrospectionQuery(array $options = []): string
130144 name
131145 {$ descriptions }
132146 {$ typeIsOneOf }
133- fields(includeDeprecated: true) {
147+ fields { $ includeDeprecatedArg } {
134148 name
135149 {$ descriptions }
136- args(includeDeprecated: true) {
150+ args { $ includeDeprecatedArg } {
137151 ...InputValue
138152 }
139153 type {
140154 ...TypeRef
141155 }
142- isDeprecated
143- deprecationReason
156+ {$ deprecationIndicators }
144157 }
145- inputFields(includeDeprecated: true) {
158+ inputFields { $ includeDeprecatedArg } {
146159 ...InputValue
147160 }
148161 interfaces {
149162 ...TypeRef
150163 }
151- enumValues(includeDeprecated: true) {
164+ enumValues { $ includeDeprecatedArg } {
152165 name
153166 {$ descriptions }
154- isDeprecated
155- deprecationReason
167+ {$ deprecationIndicators }
156168 }
157169 possibleTypes {
158170 ...TypeRef
@@ -164,8 +176,7 @@ enumValues(includeDeprecated: true) {
164176 {$ descriptions }
165177 type { ...TypeRef }
166178 defaultValue
167- isDeprecated
168- deprecationReason
179+ {$ deprecationIndicators }
169180 }
170181
171182 fragment TypeRef on __Type {
0 commit comments