GraphQL Server via Starlette
Project description
Starlette GraphQL
由starlette-graphql
包改编制成。
The starlette GraphQL implement, which support query, mutate and subscription. Based on python-gql.
Requirement
Python 3.7+
Installation
pip install starlette-graphql
Getting started
# app.py
from gql import query, gql
from stargql import GraphQL
type_defs = gql("""
type Query {
hello(name: String!): String!
}
""")
@query
async def hello(parent, info, name: str) -> str:
return name
app = GraphQL(type_defs=type_defs)
Use uvicorn to run app.
uvicorn app:app --reload
Upload File
import uvicorn
from gql import gql, mutate
from stargql import GraphQL
type_defs = gql("""
scalar Upload
type File {
filename: String!
}
type Query {
uploads: [File]
}
type Mutation {
singleUpload(file: Upload!): File!
multiUpload(files: [Upload!]!): [File!]!
}
""")
@mutate
def single_upload(parent, info, file):
return file
@mutate
def multi_upload(parent, info, files):
return files
app = GraphQL(type_defs=type_defs)
if __name__ == '__main__':
uvicorn.run(app, port=8080)
Subscription
For more about subscription, please see gql-subscriptions.
Apollo Federation
For more abount subscription, please see Apollo Federation
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-graphql-zifulu-0.0.1a6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | eca32a5d82fe47631823763dff15c67d67cee548ef81e1ad5fd8ffc30d33e9c9 |
|
MD5 | bb4b5db66fa1ca3630ef90b971bb2939 |
|
BLAKE2b-256 | 80637937a1e0f644367bc104eb7e643ee9479fc0cf5360959f5e0a585e4fe9ab |
Close
Hashes for starlette_graphql_zifulu-0.0.1a6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | adc1b47329ccb1a055b2e876df7de849e1b43091e409f054efedaf6d902bf5bd |
|
MD5 | 4b4e5f50d2e7cb56f939c4a8e0b4ab4f |
|
BLAKE2b-256 | 6b484a9859bd188406451ea33b9724b377538fdc46b5f132ef4652487c39ca7d |