Welcome to py-gql’s documentation!#

Release: v0.5.0 (Installation)

py-gql is a pure python GraphQL implementation aimed at creating GraphQL servers. It supports:

  • Parsing the GraphQL query language and schema definition language.

  • Building a GraphQL type schema programatically and from Schema Definition files (including support for schema directives).

  • Validating and executing GraphQL operations against a type schema.

The source code, issue tracker and development guidelines are available on Github.

Hello World#

# -*- coding: utf-8 -*-
from py_gql import build_schema, graphql_blocking

schema = build_schema(
    """
    type Query {
        hello(value: String = "world"): String!
    }
    """
)


@schema.resolver("Query.hello")
def resolve_hello(*, value):
    return "Hello {}!".format(value)


result = graphql_blocking(schema, '{ hello(value: "Foo") }')
assert result.response() == {"data": {"hello": "Hello Foo!"}}

GraphQL#

GraphQL is a data query language and runtime specification originally developped at Facebook and released publicly in 2015. It provides semantics for describing your data as a type schema and exposing them to clients. It is backend agnostic, which means you can freely choose the transport and serialization protocols, data storage layer, etc. that fit your project / organisation and use GraphQL as a thin layer on top.

If you are not familiar with GraphQL already, we strongly suggest you head over to graphql.org and have a look at the official introduction and the specification before going any further.

Indices and tables#