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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52e7d24c625894b1457a349280db6ab55825fc284f44b232108459a8debe1a2b |
|
MD5 | 648554ced3030a58a2de3ea28d1ab442 |
|
BLAKE2b-256 | c996080ca403486532f20ccd07202a92a6c4fbf12de8474a6178e5ade9d9f18e |
Close
Hashes for starlette_graphene3-0.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8f67157fed74f9796f602509b34c8d28bbaca048087b5c8153023013244094a |
|
MD5 | 7c29f766a20b04b5885ea79ace3295fa |
|
BLAKE2b-256 | a07c614e8699c56544fbfb2297863f54dd1c340b7a6f465d3cf22bb2d3fe4f4d |