Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Kwaidan00 opened this issue Jan 30, 2025 · 0 comments
Open
Assignees

Comments

@Kwaidan00
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants