Skip to main content

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

Metadata

Release files for starlette-graphql 0.2.1

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 0.2.1
File Size Uploaded
starlette-graphql-0.2.1.tar.gz 6.6 kB Details

Built distribution (wheel)

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

Total release size: 13.8 kB

Release files / starlette-graphql-0.2.1.tar.gz

Download URL starlette-graphql-0.2.1.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b8bb233bf202f8655e849247e29874c7fef2038f88df40acfa47cc9ff9fe5f91
BLAKE2b-256 checksum
How to use checksums
58f9b64a20747111aa342c13672bacc575db429446aedf96f385b961beacb6f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.6 Darwin/20.3.0

Release files / starlette_graphql-0.2.1-py3-none-any.whl

Download URL starlette_graphql-0.2.1-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
58226bb8a9b1778c7974bb5e89d8a564135d01add8636a5ff0339ca68291da6b
BLAKE2b-256 checksum
How to use checksums
4b44d4c8e742e933b8021593dbc0e00d2395b6287383abe57d957171dacbed67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.6 Darwin/20.3.0

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

1 release file

0.1.2

2 release files

0.1.0

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

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