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
}
}
@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.
Sadly this does not work for me using 2.0.1. :|
I keep getting None when passing null in my client. (vs undefined)
@Eraldo can you share a relevant code snippet?
Closing this down due to inactivity.
@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 dateLet me know if that answers your question and works for you.
This worked for me
Thanks!
Most helpful comment
@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:
Let me know if that answers your question and works for you.