Skip to content

Commit 0daf6d8

Browse files
committed
Merge pull request #69 from ustun/improve_object_argument_docs
Add documentation about using custom input object types as arguments
2 parents e27af63 + ab9d382 commit 0daf6d8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/pages/docs/basic-types.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,21 @@ graphene.Field(graphene.String(), to=graphene.String())
8282
# Is equivalent to:
8383
graphene.Field(graphene.String(), to=graphene.Argument(graphene.String()))
8484
```
85+
86+
87+
## Using custom object types as argument
88+
89+
To use a custom object type as an argument, you need to inherit `graphene.InputObjectType`, not `graphene.ObjectType`.
90+
91+
```python
92+
class CustomArgumentObjectType(graphene.InputObjectType):
93+
field1 = graphene.String()
94+
field2 = graphene.String()
95+
96+
```
97+
98+
Then, when defining this in an argument, you need to wrap it in an `Argument` object.
99+
100+
```python
101+
graphene.Field(graphene.String(), to=graphene.Argument(CustomArgumentObjectType))
102+
```

0 commit comments

Comments
 (0)