Skip to main content

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

starlette-graphql-0.1.2.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

starlette_graphql-0.1.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file starlette-graphql-0.1.2.tar.gz.

File metadata

  • Download URL: starlette-graphql-0.1.2.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.0 CPython/3.7.7 Darwin/19.3.0

File hashes

Hashes for starlette-graphql-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c4a9b82008dff5fc53c56f2a6209c5041d3a6a4f37ccf169c7318c835e8d284a
MD5 5c9810246e401627372c0d266edcc605
BLAKE2b-256 f551b6d11f51a50767b6703835f040cbaee61e7c63c92a640c3086c09379099d

See more details on using hashes here.

File details

Details for the file starlette_graphql-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: starlette_graphql-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.0 CPython/3.7.7 Darwin/19.3.0

File hashes

Hashes for starlette_graphql-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 623415b394229352fca31fe1d163490a28414b0b0802faa20e23f3e0599b9040
MD5 8b74117e78d4d4ae77dec5da743f1946
BLAKE2b-256 6cab3b8099eb16711da0a484168262c0750ff911734c5b46cf1d8ac98a496c26

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page