Skip to main content

No project description provided

Project description

GraphQL helpers for Python.

Schema definition

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

Using PyQL:

from pyql import Object, Schema

Query = Object('Query')

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

schema = Schema(query=Query)
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.

The whole API is currently work in progress and might change in the future.

Documentation coming as soon as things get a bit more well defined.

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

Uploaded Source

Built Distribution

PyQL-0.2.1-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: PyQL-0.2.1.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for PyQL-0.2.1.tar.gz
Algorithm Hash digest
SHA256 e95f939d8982909665a513acc3867c09c798dda596d0ee146ed084ec19f0d62d
MD5 e6f6b8e94a773d935295eb4488b1018f
BLAKE2b-256 9d057e4773d7a8097d8e5b13661822ead3f8c586ea00e8cd025d8418fa37a302

See more details on using hashes here.

File details

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

File metadata

  • Download URL: PyQL-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for PyQL-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fd5c4a3407063c3b7f87ab7dbc7b7a0e48d9156824e63b7e5fd8b9276d37cabf
MD5 571b7e44f84d1263e3ec543d1decede0
BLAKE2b-256 54379ea7f15a6efeb9234a22bfccbf483f90a4f05524fee18fdd756da96a6840

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