This is my piece of code.
class FieldMutation(graphene.Mutation):
class Arguments:
id = graphene.String(required=True)
name = graphene.String()
acres = graphene.Int()
field = graphene.Field(FieldType)
def mutate(self, info, **kwargs):
field = Field.objects.get(pk=kwargs.get("id"))
field.name = kwargs.get("name", field.name)
field.acres = kwargs.get("acres", field.acres)
field.save()
return FieldMutation(field=field)
class Mutation:
update_field = FieldMutation.Field()
schema = graphene.Schema(query=Query, mutation=Mutation)
This is my piece of code.