graphene-django icon indicating copy to clipboard operation
graphene-django copied to clipboard

null arguments being passed to mutate as kwargs

Open daynejones opened this issue 5 years ago • 3 comments

class UpdateThing(graphene.Mutation):
    class Arguments:
        guid = graphene.UUID(required=True)
        selector = graphene.String()
        note = graphene.String()

    Output = Thing

    def mutate(root, info, guid, **kwargs):
        print(kwargs)
        placement_rule = ThingAPI.update_thing(
            guid=guid,
            selector=selector,
            note=note,
        )
        return thing

Query:

mutation {
  updateThing(
    guid: "foo", selector: ".test") {
      note
  }
}

print(kwargs) prints the following:

{"guid": "foo", "selector": ".test", "note": None}

As a result, I have no idea whether note was omitted or if a null value was passed in. According to the docs, kwargs should contain only the arguments that were actually passed in. Hopefully I'm crazy and there's something I'm missing or some other canonical way of achieving what I want. Thanks for the help.

daynejones avatar Mar 24 '21 00:03 daynejones

Would be fixed with: https://github.com/graphql-python/graphene/pull/1300

zbyte64 avatar Mar 24 '21 16:03 zbyte64

How are people getting around this? This impacts query filter arguments as well

lovetoburnswhen avatar Aug 06 '21 15:08 lovetoburnswhen

Fixed: https://github.com/graphql-python/graphene/commit/19ebf08339263f0446235ddffbbab0e6d3f11699

erikwrede avatar Aug 13 '22 13:08 erikwrede