mirror of
https://github.com/graphql-python/graphene.git
synced 2025-09-21 11:22:33 +03:00
format enum mutation union examples
This commit is contained in:
parent
e761d2562f
commit
37d32de39f
|
@ -68,7 +68,7 @@ class EnumMeta(SubclassWithMeta_Meta):
|
|||
|
||||
class Enum(six.with_metaclass(EnumMeta, UnmountedType, BaseType)):
|
||||
"""
|
||||
Enum type defintion
|
||||
Enum type definition
|
||||
|
||||
Defines a static set of values that can be provided as a Field, Argument or InputField.
|
||||
|
||||
|
@ -83,9 +83,9 @@ class Enum(six.with_metaclass(EnumMeta, UnmountedType, BaseType)):
|
|||
Meta:
|
||||
enum (optional, Enum): Python enum to use as a base for GraphQL Enum.
|
||||
|
||||
name (optional, str): the name of the GraphQL type (must be unique in schema). Defaults to class
|
||||
name (optional, str): Name of the GraphQL type (must be unique in schema). Defaults to class
|
||||
name.
|
||||
description (optional, str): the description of the GraphQL type in the schema. Defaults to class
|
||||
description (optional, str): Description of the GraphQL type in the schema. Defaults to class
|
||||
docstring.
|
||||
deprecation_reason (optional, str): Setting this value indicates that the enum is
|
||||
depreciated and may provide instruction or reason on how for clients to proceed.
|
||||
|
|
|
@ -29,12 +29,14 @@ class Mutation(ObjectType):
|
|||
|
||||
.. code:: python
|
||||
|
||||
class CreatePerson(graphene.Mutation):
|
||||
class Arguments:
|
||||
name = graphene.String()
|
||||
from graphene import Mutation, String, Boolean, Field
|
||||
|
||||
ok = graphene.Boolean()
|
||||
person = graphene.Field(Person)
|
||||
class CreatePerson(Mutation):
|
||||
class Arguments:
|
||||
name = String()
|
||||
|
||||
ok = Boolean()
|
||||
person = Field(Person)
|
||||
|
||||
def mutate(parent, info, name):
|
||||
person = Person(name=name)
|
||||
|
|
|
@ -29,12 +29,14 @@ class Union(UnmountedType, BaseType):
|
|||
|
||||
.. code:: python
|
||||
|
||||
class SearchResult(graphene.Union):
|
||||
from graphene import Union, ObjectType, List
|
||||
|
||||
class SearchResult(Union):
|
||||
class Meta:
|
||||
types = (Human, Droid, Starship)
|
||||
|
||||
class Query(graphene.ObjectType):
|
||||
search = graphene.List(SearchResult.Field(
|
||||
class Query(ObjectType):
|
||||
search = List(SearchResult.Field(
|
||||
search_text=String(description='Value to search for'))
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user