Metadata-Version: 2.1
Name: starlette-graphql
Version: 0.1.2
Summary: The starlette GraphQL implement, which  support query, mutate and subscription.
Home-page: https://github.com/syfun/starlette-graphql
License: MIT
Author: syfun
Author-email: sunyu418@gmail.com
Requires-Python: >=3.7,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Requires-Dist: python-gql (<0.1)
Requires-Dist: starlette (>=0.13.3,<0.14.0)
Description-Content-Type: text/markdown

# Starlette GraphQL

The starlette GraphQL implement, which  support query, mutate and subscription. Based on [python-gql](https://github.com/syfun/python-gql).

## Requirement

Python 3.7+

## Installation

`pip install starlette-graphql`


## Getting started

```python
# 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](https://www.uvicorn.org) to run app.

`uvicorn app:app --reload`

## Upload File

```python
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](https://github.com/syfun/starlette-graphql).

