You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
Do you know if it's possible to generate input arguments dynamically from the SQLAlchemy class that will be transformed by the mutation?
Example:
My input arguments for a CreatePerson mutation look like this:
classCreatePersonInput(graphene.InputObjectType):
"""Arguments to create a person."""name=graphene.String(required=True, description="Name of the person to be created.")
height=graphene.String(default_value="unknown", description="Height of the person to be created.")
mass=graphene.String(default_value="unknown", description="Mass of the person to be created.")
hair_color=graphene.String(default_value="unknown", description="Hair color of the person to be created.")
skin_color=graphene.String(default_value="unknown", description="Skin color of the person to be created.")
eye_color=graphene.String(default_value="unknown", description="Eye color of the person to be created.")
birth_year=graphene.String(default_value="unknown", description="Birth year of the person to be created.")
gender=graphene.String(default_value="unknown", description="Gender of the person to be created.")
planet_id=graphene.ID(default_value="unknown", description="Global Id of the planet from which the person to be created comes from.")
url=graphene.String(default_value="unknown", description="URL of the person in the Star Wars API.")
classCreatePerson(graphene.Mutation):
"""Mutation to create a person."""person=graphene.Field(lambda: People, description="Person created by this mutation.")
classArguments:
input=CreatePersonInput(required=True)
...
In the meantime, the input arguments for my UpdatePerson mutation look like this:
classUpdatePersonInput(graphene.InputObjectType):
"""Arguments to update a person."""id=graphene.ID(required=True)
name=graphene.String()
height=graphene.String()
mass=graphene.String()
hair_color=graphene.String()
skin_color=graphene.String()
eye_color=graphene.String()
birth_year=graphene.String()
gender=graphene.String()
planet_id=graphene.ID()
url=graphene.String()
classUpdatePerson(graphene.Mutation):
"""Update a person."""person=graphene.Field(lambda: People, description="Person updated by this mutation.")
classArguments:
input=UpdatePersonInput(required=True)
...
Hello,
Do you know if it's possible to generate input arguments dynamically from the SQLAlchemy class that will be transformed by the mutation?
Example:
My input arguments for a
CreatePerson
mutation look like this:In the meantime, the input arguments for my
UpdatePerson
mutation look like this:Finally, my SQLAlchemy class look like this:
This is all pretty redundant and it would be ideal if we could just reuse the SQLAlchemy class attributes in the
InputObjectType
The text was updated successfully, but these errors were encountered: