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

Uploaded Source

Built Distribution

PyQL-0.2.5-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: PyQL-0.2.5.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.2

File hashes

Hashes for PyQL-0.2.5.tar.gz
Algorithm Hash digest
SHA256 3f807fd944d2d1926ef5eb6beef29076a10cebb7939f4e46b0d6149a781af49e
MD5 edfe576a94ec3a9c8b3a6093cfcb7d28
BLAKE2b-256 569f6f69700084e4654105ad6e9e2873b567e04e42aa7cb1c3fd3f14759f2ae2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: PyQL-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.2

File hashes

Hashes for PyQL-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5c4c0a0649ba37ee25e9c0d76180812dda58567e8d9c6e44da492809475c57ab
MD5 916a7ab249d9b2d7df0e4b3cafa30a16
BLAKE2b-256 5ed4d0118df784516de425e44926f070b6785f231a1d8ed30cda92f8f136ea13

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