How to make a required argument? #1173
-
Apologies for writing a question in the bugtracker but I simply can not figure out how to create a required custom argument for a query. Can anyone show me how it's done? |
Beta Was this translation helpful? Give feedback.
Answered by
maarcingebala
Dec 24, 2018
Replies: 1 comment
-
@jmn You should use class Query(graphene.ObjectType):
product = graphene.Field(
Product, id=graphene.Argument(graphene.ID, required=True),
description='Lookup a product by ID.') Now when I query for the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
zbyte64
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jmn You should use
required=True
e.g.:Now when I query for the
product
field in the API I need to pass theid
argument, as it is required to actually determine which object I should return in my resolver.