Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jordaneremieff/starlette-graphene-tortoise
An example Starlette app that uses Graphene and Tortoise ORM.
https://github.com/jordaneremieff/starlette-graphene-tortoise
asgi graphene graphql python starlette tortoise-orm
Last synced: 20 days ago
JSON representation
An example Starlette app that uses Graphene and Tortoise ORM.
- Host: GitHub
- URL: https://github.com/jordaneremieff/starlette-graphene-tortoise
- Owner: jordaneremieff
- License: mit
- Created: 2018-12-22T03:46:51.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2020-06-13T05:21:25.000Z (over 4 years ago)
- Last Synced: 2024-12-06T14:21:20.789Z (about 1 month ago)
- Topics: asgi, graphene, graphql, python, starlette, tortoise-orm
- Language: Python
- Homepage:
- Size: 7.81 KB
- Stars: 11
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# starlette-graphene-tortoise
An example of a basic [Starlette](https://github.com/encode/starlette) app using [Tortoise ORM](https://github.com/tortoise/tortoise-orm) and [Graphene](https://github.com/graphql-python/graphene).
**Requirements**: Python 3.6+
## Setup
- Setup the dev environment and install the dependencies
```
./scripts/setup
```- Activate the virtualenv
```
. venv/bin/activate
```- Create the database
```
python init_db.py
```## Running
- From the virtualenv
```
uvicorn myapp.app:app --debug
```- With docker
```
docker-compose up -d
```## GraphQL queries & mutations
Navigate to `http://localhost:8000/graphql` in your browser to access the GraphiQL console to start making queries.
### Create a user
Query:
```
mutation CreateUser($name: String!) {
createUser(name: $name) {
user {
id
name
}
}
}
```Query variables:
```
{"name": "Jordan"}
```### Update a user
Query:
```
mutation UpdateUser($id:Int!, $name: String!) {
updateUser(id: $id, name: $name) {
user {
id
name
}
}
}
```Query variables:
```
{"id" 1, "name": "Jordan Eremieff"}
```### Query an individual user
Query:
```
query User($id: Int!) {
user(id: $id) {
id
name
}
}
```Query variables:
```
{"id": 1}
```### Query all users
Query:
```
query AllUsers {
allUsers {
id
name
}
}
```