Skip to content

Latest commit

 

History

History
92 lines (61 loc) · 2.4 KB

README.md

File metadata and controls

92 lines (61 loc) · 2.4 KB

GraphQL-Env Build Status PyPI version Coverage Status

GraphQL-Env provides a GraphQL environment with pluggable query optimizers (backends) for Python GraphQL servers.

Installation

For instaling GraphQL-Env, just run this command in your shell

pip install graphql-env

Examples

Here is one example for you to get started:

from graphql_env import GraphQLEnv

# schema = graphene.Schema(...)

graphql_env = GraphQLEnv(
    schema=schema,
)

my_query = graphql_env.document_from_string('{ hello }')
result = my_query.execute()

Usage with Quiver Cloud

Quiver is a JIT compiler for GraphQL queries. It helps to improve serialization time by a factor of 5~10x.

Here is an example usage for Quiver:

from graphql_env import GraphQLEnv
from graphql_env.backend.quiver_cloud import GraphQLQuiverCloudBackend

# schema = graphene.Schema(...)

graphql_env = GraphQLEnv(
    schema=schema,
    backend=GraphQLQuiverCloudBackend(
        'http://******@api.graphql-quiver.com'
    )
)

my_query = graphql_env.document_from_string('{ hello }')
result = my_query.execute()

Note: Quiver Cloud uses requests under the hood. Systems like Google App Engine will need a monkeypatch to requests in order to work properly.

Contributing

After cloning this repo, ensure dependencies are installed by running:

pip install -e ".[test]"

After developing, the full test suite can be evaluated by running:

py.test graphql_env --cov=graphql_env --benchmark-skip # Use -v -s for verbose mode

You can also run the benchmarks with:

py.test graphql_env --benchmark-only

Documentation

The documentation is generated using the excellent Sphinx and a custom theme.

The documentation dependencies are installed by running:

cd docs
pip install -r requirements.txt

Then to produce a HTML version of the documentation:

make html