Skip to content

How can I reference an enum type created by SqlAlchemy mapping ? #96

@mariogarcia

Description

@mariogarcia

Hi:

I would like to reuse an Enum type I've mapped in one class. Lets say I had the class Patient:

class Patient(Base):
    __tablename__ = 'patients'
    id = Column(CHAR(32), default=generate_uuid, nullable=False, primary_key=True)
    name = Column(Text)
    sex = Column(Enum('MALE', 'FEMALE', name='Sex'), nullable=False)
from graphene import relay
from graphene_sqlalchemy import SQLAlchemyObjectType

from app.models.patient import Patient as PatientModel


class Patient(SQLAlchemyObjectType):
    class Meta:
        model = PatientModel
        interfaces = (relay.Node,)

That is perfectly mapped to a Sex graphql type. But if I would like to create a new Patient, How can I reference the Sex enum type generated by graphene-sqlalchemy e.g in an input type ?

class CreatePatient(relay.ClientIDMutation):
    class Input:
        name = graphene.String()
        sex = ???

BTW I'm using latest master branch version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions