format enum input object and interface examples

This commit is contained in:
Dave A 2019-06-09 09:25:08 -04:00
parent 42bfb37d26
commit e761d2562f
3 changed files with 16 additions and 8 deletions

View File

@ -74,9 +74,11 @@ class Enum(six.with_metaclass(EnumMeta, UnmountedType, BaseType)):
.. code:: python .. code:: python
class NameFormat(graphene.Enum): from graphene import Enum
FIRST_LAST = 'first_last'
LAST_FIRST = 'last_first' class NameFormat(Enum):
FIRST_LAST = "first_last"
LAST_FIRST = "last_first"
Meta: Meta:
enum (optional, Enum): Python enum to use as a base for GraphQL Enum. enum (optional, Enum): Python enum to use as a base for GraphQL Enum.

View File

@ -43,9 +43,13 @@ class InputObjectType(UnmountedType, BaseType):
.. code:: python .. code:: python
class Person(graphene.InputObjectType): from graphene import InputObjectType, String, InputField
first_name = graphene.String(required=True) # implicitly mounted as Input Field
last_name = graphene.InputField(String, description='Surname') # explicitly mounted as Input Field 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 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. mix input and output types in your schema.

View File

@ -25,9 +25,11 @@ class Interface(BaseType):
.. code:: python .. code:: python
class HasAddress(graphene.Interface): from graphene import Interface, String
class HasAddress(Interface):
class Meta: class Meta:
description = 'Address fields' description = "Address fields"
address1 = String() address1 = String()
address2 = String() address2 = String()