Skip to content

Commit 12ef70b

Browse files
committed
Set enum value values to value names in build_client_schema (#138)
Backport from main branch
1 parent 3538862 commit 12ef70b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/graphql/utilities/build_client_schema.py

+1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ def build_enum_def(enum_introspection: Dict) -> GraphQLEnumType:
175175
description=enum_introspection.get("description"),
176176
values={
177177
value_introspect["name"]: GraphQLEnumValue(
178+
value=value_introspect["name"],
178179
description=value_introspect.get("description"),
179180
deprecation_reason=value_introspect.get("deprecationReason"),
180181
)

tests/utilities/test_build_client_schema.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -382,28 +382,28 @@ def builds_a_schema_with_an_enum():
382382
# It's also an Enum type on the client.
383383
client_food_enum = assert_enum_type(client_schema.get_type("Food"))
384384

385-
# Client types do not get server-only values, so they are set to None
385+
# Client types do not get server-only values, so the values mirror the names,
386386
# rather than using the integers defined in the "server" schema.
387387
values = {
388388
name: value.to_kwargs() for name, value in client_food_enum.values.items()
389389
}
390390
assert values == {
391391
"VEGETABLES": {
392-
"value": None,
392+
"value": "VEGETABLES",
393393
"description": "Foods that are vegetables.",
394394
"deprecation_reason": None,
395395
"extensions": None,
396396
"ast_node": None,
397397
},
398398
"FRUITS": {
399-
"value": None,
399+
"value": "FRUITS",
400400
"description": None,
401401
"deprecation_reason": None,
402402
"extensions": None,
403403
"ast_node": None,
404404
},
405405
"OILS": {
406-
"value": None,
406+
"value": "OILS",
407407
"description": None,
408408
"deprecation_reason": "Too fatty.",
409409
"extensions": None,

0 commit comments

Comments
 (0)