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-gq.

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.0.8.tar.gz (5.4 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.0.8-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: starlette-graphql-0.0.8.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.2 Darwin/19.4.0

File hashes

Hashes for starlette-graphql-0.0.8.tar.gz
Algorithm Hash digest
SHA256 88613d6302c8cbdeed09218d79c6a4b8d3220f98699c16f739eaf2dd5d19e46d
MD5 19a867891dfe1ac6909c257e8128771b
BLAKE2b-256 5a7781c58436571e10eeb5870ca97c047e54353f5a35e385620428ebcf598c66

See more details on using hashes here.

File details

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

File metadata

  • Download URL: starlette_graphql-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.2 Darwin/19.4.0

File hashes

Hashes for starlette_graphql-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 94354a504757e200a94cb81699e5da9226e0177e4e236698afeb37ff4e025ddd
MD5 5181d621bc2f7aed50dc6f315469b5b7
BLAKE2b-256 aef80641c4f453f8cebd135db3e99671eae3dcd6db614d644a240082193c056f

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