Skip to content

Commit

Permalink
Merge pull request #664 from jkimbo/document-nonnull-list
Browse files Browse the repository at this point in the history
Add documentation on NonNull lists
  • Loading branch information
syrusakbary committed Feb 7, 2018
2 parents e94716d + e26c0a3 commit c044b24
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/types/list-and-nonnull.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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!]
}

0 comments on commit c044b24

Please sign in to comment.