The starlette GraphQL implement, which support query, mutate and subscription.
Project description
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file starlette-graphql-0.2.1.tar.gz.
File metadata
- Download URL: starlette-graphql-0.2.1.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.6 Darwin/20.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8bb233bf202f8655e849247e29874c7fef2038f88df40acfa47cc9ff9fe5f91
|
|
| MD5 |
795d599f166f069acd1fcd5de8f22e67
|
|
| BLAKE2b-256 |
58f9b64a20747111aa342c13672bacc575db429446aedf96f385b961beacb6f2
|
File details
Details for the file starlette_graphql-0.2.1-py3-none-any.whl.
File metadata
- Download URL: starlette_graphql-0.2.1-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.6 Darwin/20.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58226bb8a9b1778c7974bb5e89d8a564135d01add8636a5ff0339ca68291da6b
|
|
| MD5 |
07eb3432d3851b60e0e1040a8239f824
|
|
| BLAKE2b-256 |
4b44d4c8e742e933b8021593dbc0e00d2395b6287383abe57d957171dacbed67
|