graphql-python/graphene-sqlalchemy

How to generate GraphiQL documentation?

Closed this issue · 3 comments

Hello,
I'm trying to figure out how to provide descriptions to for the attributes of my SQLAlchemy class used to define my Graphene ObjectType:

from graphene_sqlalchemy import SQLAlchemyObjectType
from database.model_people import ModelPeople
import graphene


class People(SQLAlchemyObjectType):
    """People node."""

    class Meta:
        model = ModelPeople
        interfaces = (graphene.relay.Node,)

My "People node." docstring get displayed properly in GraphiQL but I'm not able to get a description for the attributes of my node which come from the ModelPeople class defined by SQLAlchemy.

image

Any idea?
Thank you

So using the doc argument of SQLAlchemy columns does the job. Example:

class ModelPeople(Base):
    """People model."""

    __tablename__ = 'people'

    id = Column('id', Integer, primary_key=True, doc="Id of the person.")
    name = Column('name', String, doc="Name of the person.")
    height = Column('height', String, doc="Height of the person.")
    mass = Column('mass', String, doc="Mass of the person.")
    hair_color = Column('hair_color', doc="Hair color of the person.")
    skin_color = Column('skin_color', String, doc="Skin color of the person.")
    eye_color = Column('eye_color', String, doc="Eye color of the person.")
    birth_year = Column('birth_year', String, doc="Birth year of the person.")
    gender = Column('gender', String, doc="Gender of the person.")
    planet_id = Column('planet_id', Integer, ForeignKey('planet.id'), doc="Id of the planet from which the person comes from.")
    created = Column('created', String, doc="Record created date.")
    edited = Column('edited', String, doc="Record last updated date.")
    url = Column('url', String, doc="URL of the person in the Star Wars API.")

Alright but what if you're using PynamoDB ?

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topics referencing this issue.