Skip to main content

Helper for add support for graphene in starlette

Project description

starlette-graphene

CI codecov pypi downloads versions license

starlette-graphene is a helper for add support for graphene in starlette.

Installation

starlette-graphene is available on PyPI. Use pip to install:

$ pip install starlette-graphene

Basic Usage

import uvicorn
from graphene import types as grt
from starlette.applications import Starlette

from starlette_graphene import GraphQLApp


class Account(grt.ObjectType):
    account = grt.Int(required=True)


class AccountFilter(grt.InputObjectType):
    accounts = grt.List(grt.Int)


class Query(grt.ObjectType):
    course_list = None
    accounts = grt.Field(
        grt.List(Account),
        filters=AccountFilter(),
    )

    async def resolve_accounts(
        self,
        info,
        filters: AccountFilter,
    ):

        return [Account(account=1212), Account(account=43434)]


def get_graphql_app() -> GraphQLApp:
    return GraphQLApp(schema=grt.Schema(query=Query))


def init_app():
    app_ = Starlette()
    app_.mount("/graphql/", get_graphql_app())
    return app_


app = init_app()

if __name__ == "__main__":
    uvicorn.run(app=app)

License

starlette-graphene is developed and distributed under the Apache 2.0 license.

Reporting a Security Vulnerability

See our security policy.

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

starlette-graphene-0.3.0.tar.gz (10.2 kB view hashes)

Uploaded Source

Built Distribution

starlette_graphene-0.3.0-py3-none-any.whl (11.2 kB view hashes)

Uploaded Python 3

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