Use Graphene v3 on Starlette
Project description
starlette_graphene3
An ASGI app for Graphene v3 (version 3). This can replace starlette.graphql.GraphQLApp
that is made for Graphene v2.
It supports:
- WebSockets (Subscriptions)
- File uploading (https://github.com/jaydenseric/graphql-multipart-request-spec)
- GraphQL Playground
import asyncio
import graphene
from graphene_file_upload.scalars import Upload
from starlette.applications import Starlette
from starlette_graphene3 import GraphQLApp
class User(graphene.ObjectType):
id = graphene.ID()
name = graphene.String()
class Query(graphene.ObjectType):
me = graphene.Field(User)
def resolve_me(root, info):
return {"id": "john", "name": "John"}
class FileUploadMutation(graphene.Mutation):
class Arguments:
file = Upload(required=True)
ok = graphene.Boolean()
def mutate(self, info, file, **kwargs):
return FileUploadMutation(ok=True)
class Mutation(graphene.ObjectType):
upload_file = FileUploadMutation.Field()
class Subscription(graphene.ObjectType):
count = graphene.Int(upto=graphene.Int())
async def subscribe_count(root, info, upto=3):
for i in range(upto):
yield i
await asyncio.sleep(1)
app = Starlette()
schema = graphene.Schema(query=Query, mutation=Mutation, subscription=Subscription)
app.mount("/", GraphQLApp(schema))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for starlette-graphene3-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cd55ecdfbaf9a8fcb4374cd9adf11fddb2ad79050a7aa7fc199a8ab1ce7fde1 |
|
MD5 | f836e12e7d44112fa0db683ebabf9696 |
|
BLAKE2b-256 | 858bd17ba1a4239f933a1d3aa0bb31e10525420dae0e90d7314cb3ccef8aaa47 |
Close
Hashes for starlette_graphene3-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02ba47abcf1195952eb30289099f2ec6b114148f884cbf4047f34c6056d91256 |
|
MD5 | 07ddec3787635d84140156826251c006 |
|
BLAKE2b-256 | 23e1601209a291a8b34f9f6ac3e242449311944e5767dca41e162ccfde9acd95 |