Skip to content

Commit 38e64b2

Browse files
authored
Adding the input_value_deprecation argument to get_introspection_query_ast (#524)
1 parent 8dd458c commit 38e64b2

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

gql/utilities/get_introspection_query_ast.py

+17-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def get_introspection_query_ast(
1010
specified_by_url: bool = False,
1111
directive_is_repeatable: bool = False,
1212
schema_description: bool = False,
13+
input_value_deprecation: bool = False,
1314
type_recursion_level: int = 7,
1415
) -> DocumentNode:
1516
"""Get a query for introspection as a document using the DSL module.
@@ -43,13 +44,20 @@ def get_introspection_query_ast(
4344

4445
directives = ds.__Schema.directives.select(ds.__Directive.name)
4546

47+
deprecated_expand = {}
48+
49+
if input_value_deprecation:
50+
deprecated_expand = {
51+
"includeDeprecated": True,
52+
}
53+
4654
if descriptions:
4755
directives.select(ds.__Directive.description)
4856
if directive_is_repeatable:
4957
directives.select(ds.__Directive.isRepeatable)
5058
directives.select(
5159
ds.__Directive.locations,
52-
ds.__Directive.args.select(fragment_InputValue),
60+
ds.__Directive.args(**deprecated_expand).select(fragment_InputValue),
5361
)
5462

5563
schema.select(directives)
@@ -69,7 +77,7 @@ def get_introspection_query_ast(
6977
fields.select(ds.__Field.description)
7078

7179
fields.select(
72-
ds.__Field.args.select(fragment_InputValue),
80+
ds.__Field.args(**deprecated_expand).select(fragment_InputValue),
7381
ds.__Field.type.select(fragment_TypeRef),
7482
ds.__Field.isDeprecated,
7583
ds.__Field.deprecationReason,
@@ -89,7 +97,7 @@ def get_introspection_query_ast(
8997

9098
fragment_FullType.select(
9199
fields,
92-
ds.__Type.inputFields.select(fragment_InputValue),
100+
ds.__Type.inputFields(**deprecated_expand).select(fragment_InputValue),
93101
ds.__Type.interfaces.select(fragment_TypeRef),
94102
enum_values,
95103
ds.__Type.possibleTypes.select(fragment_TypeRef),
@@ -105,6 +113,12 @@ def get_introspection_query_ast(
105113
ds.__InputValue.defaultValue,
106114
)
107115

116+
if input_value_deprecation:
117+
fragment_InputValue.select(
118+
ds.__InputValue.isDeprecated,
119+
ds.__InputValue.deprecationReason,
120+
)
121+
108122
fragment_TypeRef.select(
109123
ds.__Type.kind,
110124
ds.__Type.name,

tests/starwars/test_dsl.py

+2
Original file line numberDiff line numberDiff line change
@@ -984,12 +984,14 @@ def test_get_introspection_query_ast(option):
984984
specified_by_url=option,
985985
directive_is_repeatable=option,
986986
schema_description=option,
987+
input_value_deprecation=option,
987988
)
988989
dsl_introspection_query = get_introspection_query_ast(
989990
descriptions=option,
990991
specified_by_url=option,
991992
directive_is_repeatable=option,
992993
schema_description=option,
994+
input_value_deprecation=option,
993995
)
994996

995997
assert print_ast(gql(introspection_query)) == print_ast(dsl_introspection_query)

0 commit comments

Comments
 (0)