From e26c0a3717c4ff3f90ed8bd710436f8cb6ff4713 Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Wed, 7 Feb 2018 12:06:29 -0800 Subject: [PATCH] Add documentation on NonNull lists --- docs/types/list-and-nonnull.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/types/list-and-nonnull.rst b/docs/types/list-and-nonnull.rst index b48aa187..a127a9d2 100644 --- a/docs/types/list-and-nonnull.rst +++ b/docs/types/list-and-nonnull.rst @@ -48,3 +48,24 @@ Lists work in a similar way: We can use a type modifier to mark a type as a ``List``, which indicates that this field will return a list of that type. It works the same for arguments, where the validation step will expect a list for that value. + +NonNull Lists +------------- + +By default items in a list will be considered nullable. To define a list without +any nullable items the type needs to be marked as ``NonNull``. For example: + +.. code:: python + + import graphene + + class Character(graphene.ObjectType): + appears_in = graphene.List(graphene.NonNull(graphene.String)) + +The above results in the type definition: + +.. code:: + + type Character { + appearsIn: [String!] + }