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
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.

View File

@ -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.

View File

@ -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()