SHARE
TWEET

Untitled

a guest Sep 16th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import graphene
  2.  
  3. from .queries import AuthorType
  4. from ..models import Author
  5.  
  6.  
  7. class AuthorInput(graphene.InputObjectType):
  8.     id = graphene.ID()
  9.     name = graphene.String()
  10.  
  11.  
  12. class CreateAuthor(graphene.Mutation):
  13.     class Arguments:
  14.         input = AuthorInput(required=True)
  15.  
  16.     author = graphene.Field(AuthorType)
  17.  
  18.     @staticmethod
  19.     def mutate(root, info, input=None):
  20.         author_instance = Author(name=input.name)
  21.         author_instance.save()
  22.         return CreateAuthor(author=author_instance)
  23.    
  24.  
  25.  class Mutation(graphene.ObjectType):
  26.     create_author = CreateAuthor.Field()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top