Skip to main content

No project description provided

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyQL-1.0.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

PyQL-1.0.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file PyQL-1.0.0.tar.gz.

File metadata

  • Download URL: PyQL-1.0.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.1.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.7.5

File hashes

Hashes for PyQL-1.0.0.tar.gz
Algorithm Hash digest
SHA256 04559efe1ca225a6c233f7011010cd79dfdd6c4154c4f5ab4dab4bb7fddd0e3e
MD5 b723d0d5f2b1b06ca3ac5ce8ee87e020
BLAKE2b-256 74688b2c019b2439007bb41c1db1ccbd263fd2c94e32e73987197e46619e82ca

See more details on using hashes here.

File details

Details for the file PyQL-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: PyQL-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.1.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.7.5

File hashes

Hashes for PyQL-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97a1f5b90907a94c16f0ad0e992e24cdb482ed262b36a1d633c94905b8fe0d07
MD5 6a9f67ea68e134fa7bc2b61e03cf573c
BLAKE2b-256 134f7c3c682ad09d14548f88f2fca77fc2f6e149e74904cc303fcbe39e174216

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page