跳转到主要内容

Graphene GAE集成

项目描述

https://travis-ci.org/graphql-python/graphene-gae.svg?branch=master https://coveralls.io/repos/github/graphql-python/graphene-gae/badge.svg?branch=master https://img.shields.io/pypi/v/graphene-gae.svg

Graphene提供的Google AppEngine集成库

升级说明

如果您是从旧版本(2.0版本之前)升级,请查看Graphene升级指南

安装

要将Graphene-GAE安装到您的AppEngine项目中,请转到您的项目文件夹,并在shell中运行以下命令

pip install graphene-gae -t ./libs

这将安装库及其依赖项到您的项目根目录下的libs文件夹中,因此当您发布应用程序时,依赖项将与您的GAE项目一起上传。

确保libs文件夹位于您的Python路径中,请将以下内容添加到您的appengine_config.py

import sys

for path in ['libs']:
    if path not in sys.path:
        sys.path[0:0] = [path]

示例

这是一个简单的GAE模型

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)

要为它创建GraphQL模式,您只需编写以下内容

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)

然后您可以简单地查询该模式

要了解更多信息,请查看以下示例

贡献

克隆此仓库后,通过运行以下命令确保安装了依赖项:

make deps
make install

请确保正在运行测试和代码风格检查

make test
make lint

历史记录

1.0.7 (待定)

1.0.6 (2016-12-06)

  • 修复了 DeadlineExceededError 导入,swo 连接能够正确处理超时

1.0.5 (2016-11-23)

1.0.3 (2016-11-22)

1.0.2 (2016-10-20)

  • _handle_graphql_errors 钩子添加到 GraphQLHandler

1.0.1 (2016-09-28)

  • 添加了对 StructuredProperty 的支持

1.0 (2016-09-26)

  • 升级到 Graphene 1.0

0.1.9 (2016-08-17)

  • 每个 NdbObject 现在都暴露了一个映射到实体 key.id()ndbId String 字段

  • 将 ndb boolean 参数添加到 NdbKeyStringField,因此现在在查看 KeyProperty 时,可以获取全局 GraphQL id 或 NDB 内部 id。

0.1.8 (2016-08-16)

  • 使 connection_from_ndb_query 对随机的 ndb 超时具有弹性

0.1.7 (2016-06-14)

0.1.6 (2016-06-10)

0.1.5 (2016-06-08)

0.1.4 (2016-06-02)

  • NdbConnectionField 添加了可用于查询的参数
    • keys_only - 执行只获取键的查询

    • batch_size - 控制NDB查询迭代批量大小

    • page_size - 控制分页连接结果的页面大小

  • 添加了对 LocalStructuredProperty 的支持。
    • 给定属性 ndb.LocalStructuredType(Something),它将自动映射到 Field(SomethingType) - SomethingType 必须是模式的一部分。

    • 支持 repeatedrequired 属性。

0.1.3 (2016-05-27)

  • 添加了 graphene_gae.webapp2.GraphQLHandler - 一个基本的 HTTP 处理程序,用于处理 GraphQL 请求

0.1.1 (2016-05-25)

  • 将 graphene 依赖项更新到最新的 0.10.1 版本。
    • NdbConnection.from_list 现在将上下文作为参数获取

0.1.0 (2016-05-11)

  • 首次在 PyPI 上发布。

项目详情


下载文件

下载您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源分布

graphene_gae-2.0.0.tar.gz (28.3 kB 查看散列)

上传时间

支持者