Closed
Description
Say I have,
class PersonNode(DjangoObjectType):
class Meta:
model = Person
fields = ('first_name', 'last_name', 'age',
'sex', 'alive', 'unique_identifier',)
filter_fields = ('first_name', 'last_name', 'age',
'sex', 'alive', 'unique_identifier',)
interfaces = (graphene.relay.Node,)
class PersonNodeInput(graphene.InputObjectType):
first_name = graphene.String()
last_name = graphene.String()
# rest of person model fields
class Valid(graphene.ObjectType):
ok = graphene.Boolean()
class Query(graphene.ObjectType):
validate_person = graphene.Field(Valid, args={
"data": PersonNodeInput()})
person = graphene.relay.Node.Field(PersonNode)
all_people = DjangoFilterConnectionField(PersonNode)
def resolve_validate_person(root, info, data):
print("resolve validate person")
return Valid(ok=True)
Is it possible to avoid writing out PersonNodeInput? It would be nice if you could subclass something like "DjangoInputObjectType" and specify the model and fields you want in a Meta attribute.
SO question - https://stackoverflow.com/questions/66286436/is-there-a-way-to-elegantly-use-a-django-model-as-an-input-object-type
Metadata
Metadata
Assignees
Labels
No labels