Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Exclude unset fields #168

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

Open
dima-dmytruk23 wants to merge 2 commits into graphql-python:main
base: main
Choose a base branch
Loading
from dima-dmytruk23:main

Conversation

@dima-dmytruk23
Copy link

@dima-dmytruk23 dima-dmytruk23 commented Apr 25, 2022

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.

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

Reviewers

@Cito Cito Awaiting requested review from Cito Cito is a code owner

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /