Helper for add support for graphene in starlette
Project description
starlette-graphene
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.4.0.tar.gz
(10.2 kB
view details)
Built Distribution
File details
Details for the file starlette-graphene-0.4.0.tar.gz
.
File metadata
- Download URL: starlette-graphene-0.4.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a72d2783416aaf461da39bf1e2d95eb45a90d8997095cd62bfb54a53bf82b2b |
|
MD5 | 77cf76107cf8503907a3c9821baed87c |
|
BLAKE2b-256 | e9798fa5e9ba2bfce5563234504d1ccaf96c747503ff04bbfe18c17be094927b |
File details
Details for the file starlette_graphene-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: starlette_graphene-0.4.0-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc0f026548a8bae562c25934266c3409fda8e06a292516ab5933215c07ccb13e |
|
MD5 | 33d7a3d2b5347b4ecb5856d451e62b22 |
|
BLAKE2b-256 | 4ef6461cf36ecf8cfbe00f557155e0b08a40b50c65f277e369e62a6bc789a6a7 |