Skip to content

Instantly share code, notes, and snippets.

@knowsuchagency
Created February 27, 2018 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knowsuchagency/a6af5a71a71c0ae8e5e23b22eb1fb82f to your computer and use it in GitHub Desktop.
Save knowsuchagency/a6af5a71a71c0ae8e5e23b22eb1fb82f to your computer and use it in GitHub Desktop.
import graphene as g
from graphql.execution.executors.asyncio import AsyncioExecutor
class Author(g.ObjectType):
"""This is a human being."""
id = g.Int(description='The primary key in the database')
first_name = g.String()
last_name = g.String()
age = g.Int()
# we can't use g.List(Book)
# directly since it's not
# yet defined
books = g.List(lambda: Book)
class Book(g.ObjectType):
"""A book, written by an author."""
id = g.Int(description='The primary key in the database')
title = g.String(description='The title of the book')
published = g.String(description='The date it was published')
author = g.Field(Author)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment