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
|
.. 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.
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user