2

Here's the code I wrote to update my task

class UpdateTask(graphene.Mutation):

    class Input:
        id = graphene.ID()
        description = graphene.String(required=False)
        completed = graphene.Boolean()

    task = graphene.Field(Task)

    @classmethod
    def mutate(cls, root, info, **kwargs):
        task = Tasks.objects.get(id=kwargs.get('id'))
        task.description = kwargs.get('description')
        task.completed = kwargs.get('completed')
        task.save()
        return cls(task=task)

But at the time I want to update the task, the description field is required, even when I specified that is not. Any idea how to solve it?

0 Answers0