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.1a3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5382d9036e3b96f68c3abd480b0b91e15fc9a2a9ae6fd795ec2f876da22b04dc |
|
MD5 | 9558734244a9598acc71031049105e18 |
|
BLAKE2b-256 | 31b3acc37f1633d2699bf615ba7d648d2cbbeca216d1f24ab004414656780588 |
Close
Hashes for starlette_graphql_zifulu-0.0.1a3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2071306969bbaafbf513ecb5cc082b522b879ee5ed6497a6a44cedcc3128e452 |
|
MD5 | ee2ecffa9d7320fd8e7aa7032cea5250 |
|
BLAKE2b-256 | 2dbfdbd1ca9afec100bb488c56c8b3d9592934fa3acc6da86f39297ddf506733 |