A Google AppEngine integration library for Graphene
- Free software: BSD license
- Documentation: https://graphene_gae.readthedocs.org.
To install Graphene-GAE on your AppEngine project, go to your project folder and runthis command in your shell:
pip install graphene-gae -t ./libs
This will install the library and its dependencies to the libs folder under your projects root - so the dependencies get uploaded withyour GAE project when you publish your app.
Make sure the libs folder is in your python path by adding the following to your appengine_config.py:
import sys
for path in ['libs']:
if path not in sys.path:
sys.path[0:0] = [path]
Here's a simple GAE model:
class Article(ndb.Model):
headline = ndb.StringProperty()
summary = ndb.TextProperty()
text = ndb.TextProperty()
author_key = ndb.KeyProperty(kind='Author')
created_at = ndb.DateTimeProperty(auto_now_add=True)
updated_at = ndb.DateTimeProperty(auto_now=True)
To create a GraphQL schema for it you simply have to write the following:
import graphene
from graphene_gae import NdbObjectType
schema = graphene.Schema()
@schema.register
class ArticleType(NdbObjectType):
class Meta:
model = Article
class Query(graphene.ObjectType):
articles = graphene.List(ArticleType)
@graphene.resolve_only_args
def resolve_articles(self):
return Article.query()
schema.query = QueryRoot
Then you can simply query the schema:
To learn more check out the following examples:
After cloning this repo, ensure dependencies are installed by running:
make deps
make install
Make sure tests and lint are running:
make test
make lint