question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mutation update how pass null value

See original GitHub issue

model date = models.DateField(blank=True, null=True) schema date = graphene.types.datetime.Date()

mutation ($var1: Date){ updateModel( id: 1, date: $var1 ) { model { id date } } }

{"var1": null}

{ "errors": [ { "message": "mutate() missing 1 required positional argument: 'date'", "locations": [ { "line": 2, "column": 3 } ] } ], "data": { "updateModel": null } }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
spockNinjacommented, Dec 17, 2017

@juliocebrito

I haven’t tried this myself recently on the latest graphene/graphene-django versions. But based on these docs for graphene, I believe you should be able to do the following:


class UpdateModel(graphene.Mutation):
    class Arguments:
        id = graphene.ID()
        date = graphene.Date(required=False)

    @staticmethod
    def mutate(root, info, id, date=None):
        # handle empty date

Let me know if that answers your question and works for you.

0reactions
isakalcommented, Jan 5, 2020

@juliocebrito

I haven’t tried this myself recently on the latest graphene/graphene-django versions. But based on these docs for graphene, I believe you should be able to do the following:

class UpdateModel(graphene.Mutation):
    class Arguments:
        id = graphene.ID()
        date = graphene.Date(required=False)

    @staticmethod
    def mutate(root, info, id, date=None):
        # handle empty date

Let me know if that answers your question and works for you.

This worked for me Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mutation update how pass null value #1184 - GitHub
Sadly this does not work for me using 2.0.1. :| I keep getting None when passing null in my client. (vs undefined )....
Read more >
GraphQL mutation returning null on update - Stack Overflow
I am using Amazon's Amplify library for GraphQL. Create mutations are returning non-null data in the response, but update mutations return null ......
Read more >
Null input for graphql mutation - MongoDB
Hello! I am trying to create a React form component to update documents via GraphQL. I would like the form to be able...
Read more >
Using nullability in GraphQL
A field can either be nullable or non-null, and this tells you whether or not you could receive a null value when you...
Read more >
GraphQL Nullability - Episode #42
The GraphQL type system has built-in support for null, ... Now let's see what happens if we update the createUser mutation to return...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found