From ab9d382cdfe414770842c081fec3967604dae00f Mon Sep 17 00:00:00 2001 From: Ustun Ozgur Date: Fri, 11 Dec 2015 19:57:00 +0200 Subject: [PATCH] Add documentation about using custom input object types as arguments Proper indentation Add secondary field to make the intent explicit --- docs/pages/docs/basic-types.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/pages/docs/basic-types.md b/docs/pages/docs/basic-types.md index b1acb2f6..defd78b5 100644 --- a/docs/pages/docs/basic-types.md +++ b/docs/pages/docs/basic-types.md @@ -82,3 +82,21 @@ graphene.Field(graphene.String(), to=graphene.String()) # Is equivalent to: graphene.Field(graphene.String(), to=graphene.Argument(graphene.String())) ``` + + +## Using custom object types as argument + +To use a custom object type as an argument, you need to inherit `graphene.InputObjectType`, not `graphene.ObjectType`. + +```python +class CustomArgumentObjectType(graphene.InputObjectType): + field1 = graphene.String() + field2 = graphene.String() + +``` + +Then, when defining this in an argument, you need to wrap it in an `Argument` object. + +```python +graphene.Field(graphene.String(), to=graphene.Argument(CustomArgumentObjectType)) +```