Im currently having hard time on mutation enum Argument
.
Below are my code for Mutation
:
class CreatePerson(graphene.Mutation):
foo = graphene.String()
def mutate(self, info, **kwargs):
return CreatePerson(foo='foo')
class Arguments:
enum_arg = graphene.Argument(graphene.Enum.from_enum(EnumArg))
Enum class:
from enum import Enum
class EnumArg(Enum):
Baz = 0
Bar = 1
Spam = 2
Egg = 3
Command using POSTMAN:
{
"query": "mutation": {createPerson(enumArg=1) { foo }}
}
But I end up this error message:
"message": "Argument \"enumArg\" has invalid value 1.
Expected type \"EnumArg\", found 1.",
I also tried giving enumArg=\"Bar\"
on the createPerson
mutation and the error still persists.
command
is not valid python how are you calllingcommand
? – Saleratuskwargs
on thedef mutate()
, the argumentenum_arg
has a value of1
. Now the consequence problem is im usingflask-sqlalchemy
and the model field is an enum. it cannot accept value1
as it is givingNot a valid enum value
. I expected that it should give a<EnumArg.Bar: 1>
. – Microscopyflask-sqlalchemy
. I would suggest opening a new question. – Deformation