11from textwrap import dedent
2+ from typing import Optional
23
34__all__ = ["get_introspection_query" ]
45
@@ -8,6 +9,7 @@ def get_introspection_query(
89 specified_by_url : bool = False ,
910 directive_is_repeatable : bool = False ,
1011 schema_description : bool = False ,
12+ input_value_deprecation : bool = False ,
1113) -> str :
1214 """Get a query for introspection.
1315
@@ -19,6 +21,10 @@ def get_introspection_query(
1921 maybe_specified_by_url = "specifiedByUrl" if specified_by_url else ""
2022 maybe_directive_is_repeatable = "isRepeatable" if directive_is_repeatable else ""
2123 maybe_schema_description = maybe_description if schema_description else ""
24+
25+ def input_deprecation (string : str ) -> Optional [str ]:
26+ return string if input_value_deprecation else ""
27+
2228 return dedent (
2329 f"""
2430 query IntrospectionQuery {{
@@ -35,7 +41,7 @@ def get_introspection_query(
3541 { maybe_description }
3642 { maybe_directive_is_repeatable }
3743 locations
38- args {{
44+ args{ input_deprecation ( "(includeDeprecated: true)" ) } {{
3945 ...InputValue
4046 }}
4147 }}
@@ -50,7 +56,7 @@ def get_introspection_query(
5056 fields(includeDeprecated: true) {{
5157 name
5258 { maybe_description }
53- args {{
59+ args{ input_deprecation ( "(includeDeprecated: true)" ) } {{
5460 ...InputValue
5561 }}
5662 type {{
@@ -59,7 +65,7 @@ def get_introspection_query(
5965 isDeprecated
6066 deprecationReason
6167 }}
62- inputFields {{
68+ inputFields{ input_deprecation ( "(includeDeprecated: true)" ) } {{
6369 ...InputValue
6470 }}
6571 interfaces {{
@@ -81,6 +87,8 @@ def get_introspection_query(
8187 { maybe_description }
8288 type {{ ...TypeRef }}
8389 defaultValue
90+ { input_deprecation ("isDeprecated" )}
91+ { input_deprecation ("deprecationReason" )}
8492 }}
8593
8694 fragment TypeRef on __Type {{
0 commit comments