https://github.com/petr-korobeinikov/graphql-python-showcase
Stop using REST, Post-JSON, and other stuff from 2k00.
https://github.com/petr-korobeinikov/graphql-python-showcase
example graphene graphene-python graphql graphql-api showcase starlette
Last synced: 11 months ago
JSON representation
Stop using REST, Post-JSON, and other stuff from 2k00.
- Host: GitHub
- URL: https://github.com/petr-korobeinikov/graphql-python-showcase
- Owner: petr-korobeinikov
- Created: 2021-02-06T00:19:26.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-02-14T22:18:36.000Z (about 3 years ago)
- Last Synced: 2025-02-16T21:47:24.606Z (about 1 year ago)
- Topics: example, graphene, graphene-python, graphql, graphql-api, showcase, starlette
- Language: Python
- Homepage:
- Size: 619 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# graphql-python-showcase
### Stop using REST, Post-JSON, and other stuff from 2k00.
## Running the project
```shell
DOCKER_BUILDKIT=1 docker build -t graphql-python-showcase .
docker run --rm -p 9000:9000 graphql-python-showcase
```
Open `http://:9000/`.

## Running queries
### Find all projects
```graphql
query allProjects {
projects {
id
name
slug
}
}
```
### Find all project names
```graphql
query allProjectNames {
projects {
name
}
}
```
### Find all project with tasks
```graphql
query allProjectsWithTasks {
projects {
id
name
tasks {
id
title
}
}
}
```
### Find project by slug (query variable demo)
```graphql
query projectBySlug($slug: String!) {
projectBySlug(slug: $slug) {
id
name
slug
}
}
```
Provide a required `slug` variable:
```json
{
"slug": "proj1"
}
```
### Using directive example
```graphql
query projectWithTasksBySlug($slug: String!, $withTasks: Boolean!) {
projectBySlug(slug: $slug) {
id
name
slug
tasks @include(if: $withTasks) {
id
title
}
}
}
```
```json
{
"slug": "proj1",
"withTasks": true
}
```
### Find assignees
```graphql
query projectBySlug($slug: String!) {
projectBySlug(slug: $slug) {
id
name
slug
tasks {
id
title
assignee {
id
name
}
}
}
}
```
### Type introspection
```graphql
query projectBySlugIntrospected($slug: String!) {
projectBySlug(slug: $slug) {
__typename
id
name
slug
tasks {
__typename
id
title
assignee {
__typename
id
name
}
}
}
}
```
## Running mutations
### Create a project
todo: use variables
```graphql
mutation createProject {
createProject(name: "Project 4", slug: "prj4") {
project {
id
name
slug
}
ok
}
}
```
### Reassign a task
todo: use variables
```graphql
mutation reassignTask {
reassignTask(taskId: 1, assigneeId: 2) {
task {
id
assignee {
id
name
}
}
ok
}
}
```
## TODO
Add:
* Enums (task status)
* Pagination
* Fragments
* Auth
## Python + GraphQL quick start
* [docs.graphene-python.org/en/latest/quickstart/](https://docs.graphene-python.org/en/latest/quickstart/)
* [www.starlette.io/graphql/](https://www.starlette.io/graphql/)
## Main GraphQL learning resource
* [graphql.org](https://graphql.org/)
* [graphql.org/learn/](https://graphql.org/learn/)
## Free learning resources
* [www.howtographql.com](https://www.howtographql.com)
* [www.graphqlweekly.com](https://www.graphqlweekly.com/)
## Paid learning resources
* [app.pluralsight.com/library/courses/graphql-big-picture/table-of-contents](https://app.pluralsight.com/library/courses/graphql-big-picture/table-of-contents)
* [egghead.io/courses/graphql-query-language](https://egghead.io/courses/graphql-query-language)
* [egghead.io/courses/designing-graphql-schemas-99db](https://egghead.io/courses/designing-graphql-schemas-99db)
* [packtpub.com/application-development/beginning-graphql-elearning](https://www.packtpub.com/application-development/beginning-graphql-elearning)
* [packtpub.com/application-development/practical-graphql-become-graphql-ninja-video](https://www.packtpub.com/application-development/practical-graphql-become-graphql-ninja-video)
* [packtpub.com/web-development/hands-full-stack-web-development-graphql-and-react](https://www.packtpub.com/web-development/hands-full-stack-web-development-graphql-and-react)