Skip to content

Commit e26c0a3

Browse files
committed
Add documentation on NonNull lists
1 parent e94716d commit e26c0a3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/types/list-and-nonnull.rst

+21
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,24 @@ Lists work in a similar way: We can use a type modifier to mark a type as a
4848
``List``, which indicates that this field will return a list of that type.
4949
It works the same for arguments, where the validation step will expect a list
5050
for that value.
51+
52+
NonNull Lists
53+
-------------
54+
55+
By default items in a list will be considered nullable. To define a list without
56+
any nullable items the type needs to be marked as ``NonNull``. For example:
57+
58+
.. code:: python
59+
60+
import graphene
61+
62+
class Character(graphene.ObjectType):
63+
appears_in = graphene.List(graphene.NonNull(graphene.String))
64+
65+
The above results in the type definition:
66+
67+
.. code::
68+
69+
type Character {
70+
appearsIn: [String!]
71+
}

0 commit comments

Comments
 (0)