Graphene GAE Integration
A Google AppEngine integration library for Graphene
- Free software: BSD license
- Documentation: https://graphene_gae.readthedocs.org.
If you’re upgrading from an older version (pre 2.0 version) please check out the Graphene Upgrade Guide.
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 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 = graphene.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
- GraphQLHandler GET supoort ([PR #27](https://github.com/graphql-python/graphene-gae/pull/27))
- Fixed DeadlineExceededError import swo connections properly handle timeouts
- Improved behavior of NdbConnectionField when transform_edges also filters out some edges ([PR #26](https://github.com/graphql-python/graphene-gae/pull/25))
- Added transform_edges to NdbConnectionField ([PR #25](https://github.com/graphql-python/graphene-gae/pull/25))
- Added _handle_graphql_errors hook to GraphQLHandler
- Added missing support for StructuredProperty
- Upgraded to Graphene 1.0
- Each NdbObject now exposes an ndbId String field that maps to the entity’s key.id()
- Added ndb boolean argument to NdbKeyStringField so now when looking at KeyProperty we can fetch either global GraphQL id or the NDB internal id.
- Made connection_from_ndb_query resilient to random ndb timeouts
- BREAKING: Fixed behavior of KeyProperty to expose GraphQL Global IDs instead of internal ndb.Key values. ([PR #16](https://github.com/graphql-python/graphene-gae/pull/16))
- Changing development status to Beta
- Added NdbNode.global_id_to_key [PR #15](https://github.com/graphql-python/graphene-gae/pull/15)
- Fixed behavior of ndb.KeyProperty ([PR #14](https://github.com/graphql-python/graphene-gae/pull/14))
- NdbConnectionField added arguments that can be used in quert:
- keys_only - to execute a keys only query
- batch_size - to control the NDB query iteration batch size
- page_size - control the page sizes when paginating connection results
- Added support for LocalStructuredProperty.
- Given a property ndb.LocalStructuredType(Something) it will automatically map to a Field(SomethingType) - SomethingType has to be part of the schema.
- Support for repeated and required propeties.
- Added graphene_gae.webapp2.GraphQLHandler - a basic HTTP Handler to process GraphQL requests
- Updated graphene dependency to latest 0.10.1 version.
- NdbConnection.from_list now gets context as parameter
- First release on PyPI.