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

Differentiate explicit null vs. not provided fields #1118

Closed
weilu opened this issue Feb 15, 2021 · 2 comments
Closed

Differentiate explicit null vs. not provided fields #1118

weilu opened this issue Feb 15, 2021 · 2 comments
Labels

Comments

@weilu
Copy link

weilu commented Feb 15, 2021

  • What is the current behavior?

Currently explicitly supplying null value in a mutation query and leaving out a field & its value resulted in the same {'field': None} value in the mutate function, instead of what was described by @jkimbo in #103

Say this is my schema:

type UserType {
  id: ID!
  name: String!
  phone: String!
}

This is the UserMutation defined in schema.py:

class MediatorMutation(graphene.Mutation):
    class Arguments:
        id = graphene.ID(required=True)
        name = graphene.String()
        phone = graphene.String()

    user = graphene.Field(UserType)

    def mutate(self, info, **args):
        print(args)
        return UserMutation(user=user)

This is my mutation query:

mutation {
  updateUser(id: 1, phone: null){
    user {
      id
      name
      phone
    }
  }
}
  • What is the expected behavior?

I expect the print line to be {'id': '1', 'phone': None}, but it's currently printing {'id': '1', 'name': None, 'phone': None}

  • What is the motivation / use case for changing the behavior?

This is important for updating when we want to set a nullable field to null/None. See relevant GraphQL spec change: graphql/graphql-spec#83

  • Please tell us about your environment:

    • Version: graphene-django==3.0.0b7
    • Platform: macos
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)

I just want to hear maintainer & community's thoughts on this and if it's just a user issue on my end. Happy to send a patch/PR once we confirm this is indeed a bug.

@weilu weilu added the 🐛bug label Feb 15, 2021
@zbyte64
Copy link
Collaborator

zbyte64 commented Feb 17, 2021

This would probably be a PR with graphene so I took a look and there is an open PR for it: graphql-python/graphene#1300

@weilu
Copy link
Author

weilu commented Feb 17, 2021

Makes sense. Thanks for looking into this. I’m closing this issue since there’s already one upstream

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

2 participants