Skip to content

Default default_value should be Undefined instead of None in Argument and Field #1344

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

Closed
steverice opened this issue Jun 29, 2021 · 3 comments
Labels

Comments

@steverice
Copy link

In graphql-core, the default_value for a GraphQLArgument is set to Undefined if it is not given. This corresponds to the behavior in value_from_ast, in which an argument that has not been supplied is given the default_value iff that default is not Undefined.

In other words, if the code specifies a default_value for an argument, use it if there is no value provided. If the code does not specify a default_value, do not supply a default value if none is provided.

Graphene breaks this expectation by setting the default_value to None if none is provided in Argument and in Field.

This was resolved for InputField in #1111, but it should also be changed for Argument and Field since a Field can be mounted as an Argument.

From that PR:

Since GraphQL 3.0 there is a distinction between None and INVALID (no value).
See also graphql-python/graphql-core#66 (comment)
I think there are more bugs of this kind, but since I don't know graphene well, yet, I take baby steps.

@samopus1io
Copy link

Hi is there an update on this? we have the exact same problem and cant migrate to graphene 3 because of this - it is breaking all our APIs pretty much.

@tlinhart
Copy link

I've just encountered this issue as it breaks our API as well. It seems it was fixed in 19ebf08, at least for the Argument type.

@erikwrede
Copy link
Member

As @tlinhart mentioned, this is fixed in the newest release.

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

No branches or pull requests

4 participants