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:
- Queries and Mutations (over HTTP or WebSocket)
- Subscriptions (over WebSocket)
- File uploading (https://github.com/jaydenseric/graphql-multipart-request-spec)
- GraphQL Playground
Installation
pip3 install -U starlette-graphene3
Example
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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d08e5bdae9eaf424fd26014e0b9ff054eea1d25c80560eb527d91ef0c88f6e12 |
|
MD5 | a81315dd96d83d1aa946e239b23d8076 |
|
BLAKE2b-256 | 99eb1c7c3ea793b61875a063adbaa2151150aae5b4c869bff083445a6f947b49 |
Close
Hashes for starlette_graphene3-0.2.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5389f80effc7a9062fd376e264b6ae109f6bb8dc8ca3311a7f456a8363d3fb1 |
|
MD5 | d7a383423f90ca89cc6d43236e693e16 |
|
BLAKE2b-256 | ad4ce7e3d376ede91a89a359ea31c6bf54f3d7dd50ea77277c0a252a978e7f5b |