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

Exclude unset fields #168

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dima-dmytruk23
Copy link

Original discussion: graphql-python/graphene-pydantic#75

I use graphene and graphene-pydantic libraries.
Code example:
https://gist.github.com/dima-dmytruk23/aaeba0fbc7a539c1f8bf3d0914fce580

The client does not pass the name field, but it is still present in the mutation as None. Input query turns into a UserUpdateInput, which is when the default values are filled in to the dictionary. So then when your code passes the dictionary in to build the UserUpdate, it sets all the fields -- so exclude_unset doesn't exclude anything, since all the fields were in fact set.

I am fairly sure it's not in graphene-pydantic, though, since that is only responsible for converting to the GrapheneInputObjectType.

I propose to resolve this issue by adding the exclude unset flag to the GraphQLSchema class and use it in the coerce_input_value function.

@Cito
Copy link
Member

Cito commented Apr 30, 2022

Hi @dima-dmytruk23, and thanks for contributing.

Please understand that the scope of GraphQL-core is to be a straight-forward port of GraphQL.js, so I am very reluctant to add features that are not part of GraphQL.js or change the API. I'm not saying that we can never do this, and we in fact have serveral such extensions, but you really need to have convincing reasons why this is necessary. Any such extension makes maintaining GraphQL-core and keeping it in sync with GraphQL.js more difficult as they sum up.

Therefore, could you please first open an issue and explain what the feature tries to achieve, and how it could be useful and why it cannot be achieved in other ways, with example code, independent of Graphene or Graphene-Pydantic? We also require unit tests, and this will help to create them.

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

Successfully merging this pull request may close these issues.

None yet

2 participants