Skip to content

Enum default values repair does not work properly with graphql-core 3.2.6 #1216

Open
@Kwaidan00

Description

@Kwaidan00

The graphql-core 3.2.6 (https://github.com/graphql-python/graphql-core/releases/tag/v3.2.6) introduced default values transforming for input objects. It breaks the Ariadne logic for repairing default values for enum.

Especially, the following automatic test fails:

FAILED tests/test_graphql_enum_fixes.py::test_enum_with_int_values_from_dict - assert not [GraphQLError("Invalid value 0 at 'value.role': Enum 'Role' cannot represent non-string value: 0.", locations=[SourceLocation(line=13, column=9)], path=['argInputObjType'])]
FAILED tests/test_graphql_enum_fixes.py::test_enum_with_int_enum_values - assert not [GraphQLError("Invalid value <Role.USER: 0> at 'value.role': Enum 'Role' cannot represent non-string value: <Role.USER: 0>.", locations=[SourceLocation(line=13, column=9)], path=['argInputObjType'])]
FAILED tests/test_graphql_enum_fixes.py::test_enum_with_str_enum_values - assert not [GraphQLError("Invalid value <Role.USER: 'u'> at 'value.role': Value 'u' does not exist in 'Role' enum.", locations=[SourceLocation(line=13, column=9)], path=['argInputObjType'])]

I can also provide minimal example of the failing code, but I think tests are sufficient here.

Since graphql-core started to call its logic of transforming (coerce_input_value), it sounds like the Ariadne's repair logic is not needed anymore: graphql-core needs enum name instead of value and parse it on its side. However, this transforming is called only for some cases (argument type has to be GraphQLInputObjectType). For arguments of type enum or lists - the repair logic has to stay and it should work in the previous way.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions