Skip to content

Commit 6fb9058

Browse files
committed
introspection: expose fields/values with empty deprecation_reason
Replicates graphql/graphql-js@dd95ec2
1 parent 2d7949f commit 6fb9058

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/graphql/type/introspection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def fields(type_, _info, includeDeprecated=False):
276276
if is_object_type(type_) or is_interface_type(type_):
277277
items = type_.fields.items()
278278
if not includeDeprecated:
279-
return [item for item in items if not item[1].deprecation_reason]
279+
return [item for item in items if not item[1].is_deprecated]
280280
return list(items)
281281

282282
@staticmethod
@@ -295,7 +295,7 @@ def enum_values(type_, _info, includeDeprecated=False):
295295
if is_enum_type(type_):
296296
items = type_.values.items()
297297
if not includeDeprecated:
298-
return [item for item in items if not item[1].deprecation_reason]
298+
return [item for item in items if not item[1].is_deprecated]
299299
return items
300300

301301
@staticmethod

tests/type/test_introspection.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,9 @@ def identifies_deprecated_fields():
975975
"deprecated": GraphQLField(
976976
GraphQLString, deprecation_reason="Removed in 1.0"
977977
),
978+
"deprecatedWithEmptyReason": GraphQLField(
979+
GraphQLString, deprecation_reason=""
980+
),
978981
},
979982
)
980983

@@ -1007,6 +1010,11 @@ def identifies_deprecated_fields():
10071010
"isDeprecated": True,
10081011
"deprecationReason": "Removed in 1.0",
10091012
},
1013+
{
1014+
"name": "deprecatedWithEmptyReason",
1015+
"isDeprecated": True,
1016+
"deprecationReason": "",
1017+
},
10101018
],
10111019
}
10121020
},
@@ -1112,7 +1120,10 @@ def respects_the_include_deprecated_parameter_for_enum_values():
11121120
{
11131121
"NON_DEPRECATED": GraphQLEnumValue(0),
11141122
"DEPRECATED": GraphQLEnumValue(1, deprecation_reason="Removed in 1.0"),
1115-
"ALSO_NON_DEPRECATED": GraphQLEnumValue(2),
1123+
"DEPRECATED_WITH_EMPTY_REASON": GraphQLEnumValue(
1124+
2, deprecation_reason=""
1125+
),
1126+
"ALSO_NON_DEPRECATED": GraphQLEnumValue(3),
11161127
},
11171128
)
11181129

@@ -1122,7 +1133,6 @@ def respects_the_include_deprecated_parameter_for_enum_values():
11221133
source = """
11231134
{
11241135
__type(name: "TestEnum") {
1125-
name
11261136
trueValues: enumValues(includeDeprecated: true) {
11271137
name
11281138
}
@@ -1139,10 +1149,10 @@ def respects_the_include_deprecated_parameter_for_enum_values():
11391149
assert graphql_sync(schema=schema, source=source) == (
11401150
{
11411151
"__type": {
1142-
"name": "TestEnum",
11431152
"trueValues": [
11441153
{"name": "NON_DEPRECATED"},
11451154
{"name": "DEPRECATED"},
1155+
{"name": "DEPRECATED_WITH_EMPTY_REASON"},
11461156
{"name": "ALSO_NON_DEPRECATED"},
11471157
],
11481158
"falseValues": [

0 commit comments

Comments
 (0)