mirror of
https://github.com/graphql-python/graphene.git
synced 2025-09-21 11:22:33 +03:00
format enum input object and interface examples
This commit is contained in:
parent
42bfb37d26
commit
e761d2562f
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue
Block a user