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-0.4.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

PyQL-0.4.0-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: PyQL-0.4.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3

File hashes

Hashes for PyQL-0.4.0.tar.gz
Algorithm Hash digest
SHA256 cb5cf1077c052d61b236923537b4652d7f8162fdf3885d4ca81e527149e4c148
MD5 2f93271f40094b43280eaabae3b5f870
BLAKE2b-256 8aec049c461fa9bbd23bf48b28c0e08ba2eb79c6d90fcc23dc65736a0e10249c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: PyQL-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3

File hashes

Hashes for PyQL-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 020708f292a8fb051b6aef7f2cc7f60da4261338206a97abba70360a0e2d7afd
MD5 8b9c6d6380798eab6dfa6afd9ef26f95
BLAKE2b-256 008e37db200208db73e7a26229b4870737483a1f1449368f04e53f52e9cad638

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