Skip to content

Enum default_value serialization issue #691

Closed
@nikordaris

Description

@nikordaris

Using graphene 2.0.1

class MyEnum(graphene.Enum):
    FOO=0
    BAR=1

foobar = graphene.List(FooBar, my_enum=graphene.Argument(MyEnum, default_value=MyEnum.FOO.name))

This results in the defaultValue being "\"FOO\"". This does not follow the graphql spec for enums and breaks with third party introspection. Specifically i'm trying to stitch a graphene remote schema and the invalid defaultValue results in a null returned in the merged schema (using graphql-tools).

class MyEnum(graphene.Enum):
    FOO="FOO"
    BAR="BAR"

This also doesn't work with using MyEnum.FOO.value for default_value nor setting it specifically to the string "FOO"

I tried looking for how default_value gets resolved for enums but haven't been able to track it down. I think if we can just get the string value for default_value to not include the escaped string quotes then my schema stitching will work. I haven't been able to figure out how to define an enum so that this will happen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions