Use Graphene v3 on Starlette
Project description
starlette_graphene3
An ASGI app for Graphene v3. 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_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 {'count': 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.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6244bfe63ddc8c5cd446d7881765870e7d8ed5440fbb0078572bd9e27e6cae73 |
|
MD5 | 7fe474ff0beb1e73c36e2516d7125e0e |
|
BLAKE2b-256 | 7dc34e34b0982af2c8336fc4e3efbbd3b31edd631cf0306e4b25c526a7e32e9c |
Close
Hashes for starlette_graphene3-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fdfe963bec43050fbd23577f23b21a85346be828b84e9bbb7a0686723bbd2990 |
|
MD5 | e9f70d969924b69fd7b4c1e8ffe88b3f |
|
BLAKE2b-256 | fe7190740960f373635aeb570bc34d671ba3ef20d56cfabedbc6f3b14e8bec30 |