From e761d2562f0e40c283cf82e072e74aff7a5ebfd4 Mon Sep 17 00:00:00 2001 From: Dave A Date: Sun, 9 Jun 2019 09:25:08 -0400 Subject: [PATCH] format enum input object and interface examples --- graphene/types/enum.py | 8 +++++--- graphene/types/inputobjecttype.py | 10 +++++++--- graphene/types/interface.py | 6 ++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/graphene/types/enum.py b/graphene/types/enum.py index 41888505..5a21e32f 100644 --- a/graphene/types/enum.py +++ b/graphene/types/enum.py @@ -74,9 +74,11 @@ class Enum(six.with_metaclass(EnumMeta, UnmountedType, BaseType)): .. code:: python - class NameFormat(graphene.Enum): - FIRST_LAST = 'first_last' - LAST_FIRST = 'last_first' + from graphene import Enum + + class NameFormat(Enum): + FIRST_LAST = "first_last" + LAST_FIRST = "last_first" Meta: enum (optional, Enum): Python enum to use as a base for GraphQL Enum. diff --git a/graphene/types/inputobjecttype.py b/graphene/types/inputobjecttype.py index 1d3e99d8..d1368931 100644 --- a/graphene/types/inputobjecttype.py +++ b/graphene/types/inputobjecttype.py @@ -43,9 +43,13 @@ class InputObjectType(UnmountedType, BaseType): .. code:: python - class Person(graphene.InputObjectType): - first_name = graphene.String(required=True) # implicitly mounted as Input Field - last_name = graphene.InputField(String, description='Surname') # explicitly mounted as Input Field + from graphene import InputObjectType, String, InputField + + class Person(InputObjectType): + # implicitly mounted as Input Field + first_name = String(required=True) + # explicitly mounted as Input Field + last_name = InputField(String, description="Surname") The fields on an input object type can themselves refer to input object types, but you can't mix input and output types in your schema. diff --git a/graphene/types/interface.py b/graphene/types/interface.py index 2148259b..bb9cf13e 100644 --- a/graphene/types/interface.py +++ b/graphene/types/interface.py @@ -25,9 +25,11 @@ class Interface(BaseType): .. code:: python - class HasAddress(graphene.Interface): + from graphene import Interface, String + + class HasAddress(Interface): class Meta: - description = 'Address fields' + description = "Address fields" address1 = String() address2 = String()