Skip to main content

PyQL

GraphQL helpers for Python.

CI status: ci-status

Schema definition

PyQL provides a better / cleaner syntax for defining GraphQL schemas.

Using PyQL:

from pyql import Schema

schema = Schema()

@schema.query.field('hello')
def resolve_hello(root, info, name: str = 'world') -> str:
    return 'Hello {}'.format(name)

compiled = schema.compile()

Equivalent using graphql-core:

from graphql import (
    GraphQLObjectType, GraphQLField, GraphQLArgument, GraphQLString,
    GraphQLSchema)

Query = GraphQLObjectType(
    'Query',
    fields=lambda: {
        'hello': GraphQLField(
            GraphQLString,
            args={
                'name': GraphQLArgument(
                    type=GraphQLString,
                    default_value='world',
                ),
            },
            resolver=lambda root, info, name = 'world': f'Hello, {name}'
        ),
    }
)

schema = GraphQLSchema(query=Query)

Graphene looks slightly better, but it’s quite confusing, and makes use of unncessary objects:

import graphene

class Query(graphene.ObjectType):
    hello = graphene.Field(
        graphene.String,
        name=graphene.Argument(graphene.String))

    def resolve_hello(self, info, name='world'):
        return f'Hello {name}'

schema = graphene.Schema(query=Query)

PyQL uses standard Python introspection when possible to figure out things, so eg. argument definitions can be picked up automatically from a resolver function, etc.

Limitations

While there are plans for field argument documentation to be picked up automatically from docstrings, it’s not currently implemented as reliably parsing docstrings is a non-trivial task.

Release files for PyQL 3.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyQL 3.0.0
File Size Uploaded
PyQL-3.0.0.tar.gz 10.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PyQL 3.0.0
File Interpreter ABI Platform
PyQL-3.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.2 kB

Release files / PyQL-3.0.0.tar.gz

Download URL PyQL-3.0.0.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4f75a5bb9cbe66c53832234e8f8699de44b35c73b085afc242ca427ab6569e12
BLAKE2b-256 checksum
How to use checksums
0dc29a4a9208c367f6ed9a2b48b1dd4c4af95ea6122c98f72ec83f161c1acab8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.5

Release files / PyQL-3.0.0-py3-none-any.whl

Download URL PyQL-3.0.0-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23e23f9c601ef548aa42f446b7873c8beaaf0d3003583187bbcd630da5d7a997
BLAKE2b-256 checksum
How to use checksums
271025727c5dad1731a92a63d9503ba3c6c6f61cea562ae01e90b6faefbed2f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

3.0.0 This release

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page