Skip to content

Enum instances aren't mounted as Fields #932

Closed
@thejcannon

Description

@thejcannon

Howdy folks!

I've been running into an issue with my enum fields not being in my schema, which I think is because the Enum instance is being skipped when mounting the unmounted fields.

>>> isinstance(Enum('Foo', [('X', 1)]), UnmountedType)
False
>>> isinstance(Int(), UnmountedType)
True
>>> isinstance(Enum('Foo', [('X', 1)])(), UnmountedType)
True

Which has to do with the weirdness of Python enums, but isn't unexpected:

>>> type(Enum('Foo', [('X', 1)]))
<class 'graphene.types.enum.EnumMeta'>
>>> type(Enum('Foo', [('X', 1)])())
<Foo meta=<EnumOptions name='Foo'>>

Unfortunately, the documentation doesn't mention using Enums in relation to fields (Either like a scalar, or as the "type" in a Field) but that's possibly a separate issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions