format enum mutation union examples

This commit is contained in:
Dave A 2019-06-09 09:32:49 -04:00
parent e761d2562f
commit 37d32de39f
3 changed files with 15 additions and 11 deletions

View File

@ -68,7 +68,7 @@ class EnumMeta(SubclassWithMeta_Meta):
class Enum(six.with_metaclass(EnumMeta, UnmountedType, BaseType)): 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. 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: 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.
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. 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. docstring.
deprecation_reason (optional, str): Setting this value indicates that the enum is 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. depreciated and may provide instruction or reason on how for clients to proceed.

View File

@ -29,12 +29,14 @@ class Mutation(ObjectType):
.. code:: python .. code:: python
class CreatePerson(graphene.Mutation): from graphene import Mutation, String, Boolean, Field
class Arguments:
name = graphene.String()
ok = graphene.Boolean() class CreatePerson(Mutation):
person = graphene.Field(Person) class Arguments:
name = String()
ok = Boolean()
person = Field(Person)
def mutate(parent, info, name): def mutate(parent, info, name):
person = Person(name=name) person = Person(name=name)

View File

@ -29,12 +29,14 @@ class Union(UnmountedType, BaseType):
.. code:: python .. code:: python
class SearchResult(graphene.Union): from graphene import Union, ObjectType, List
class SearchResult(Union):
class Meta: class Meta:
types = (Human, Droid, Starship) types = (Human, Droid, Starship)
class Query(graphene.ObjectType): class Query(ObjectType):
search = graphene.List(SearchResult.Field( search = List(SearchResult.Field(
search_text=String(description='Value to search for')) search_text=String(description='Value to search for'))
) )