Skip to main content

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

Example

For more abount subscription, please see Apollo Federation

Release files for starlette-graphql-zifulu 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for starlette-graphql-zifulu 0.0.3
File Size Uploaded
starlette-graphql-zifulu-0.0.3.tar.gz 7.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for starlette-graphql-zifulu 0.0.3
File Interpreter ABI Platform
starlette_graphql_zifulu-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 15.4 kB

Release files / starlette-graphql-zifulu-0.0.3.tar.gz

Download URL starlette-graphql-zifulu-0.0.3.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
20d1959a1ef5c4ef707219a8e3616ffd55e2c50721859bc4665ad616f3c8b09e
BLAKE2b-256 checksum
How to use checksums
c74b0cf215a97748a695680b384f9ddaa8f6d6fd14e4285ebc43ca0e8a02604b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / starlette_graphql_zifulu-0.0.3-py3-none-any.whl

Download URL starlette_graphql_zifulu-0.0.3-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7fb19faf2b90156f2a10cd0bcdfab9fdc9798d060cd1cca39f8c598f2213346b
BLAKE2b-256 checksum
How to use checksums
3f7a483a5938bbbe9968b9fc2d5cd5a759f63c544906578f3fe19013cfae199f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page