https://github.com/renanstn/flask-graphql-example
Exemplo simples de app utilizando Flask e Graphql.
https://github.com/renanstn/flask-graphql-example
flask graphql python
Last synced: 2 months ago
JSON representation
Exemplo simples de app utilizando Flask e Graphql.
- Host: GitHub
- URL: https://github.com/renanstn/flask-graphql-example
- Owner: renanstn
- Created: 2020-05-29T22:22:32.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-05-01T21:41:31.000Z (about 3 years ago)
- Last Synced: 2025-03-23T13:43:18.584Z (over 1 year ago)
- Topics: flask, graphql, python
- Language: Python
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Flask Graphql Example
*Aplicação em Flask utilizando graphql, desenvolvida para estudo.*
Me baseei [neste](https://dev.to/mesadhan/python-flask-graphql-with-graphene-nla) artigo, porém alterei todo o código para maior organização
## Subindo o ambiente
- Crie e ative um `virtualenv` com os comandos
- `python -m venv venv`
- `source venv/bin/activate` *(linux)*
- `venv\Scripts\activate` *(windows)*
- Instale as dependências
- `pip install -r requirements.txt`
- Crie alguns dados fakes no banco executando o script:
- `python seed.py`
- Suba a aplicação com:
- `python run.py`
## Utilizando
Utilize algum client com o insomnia para fazer as requests de **query** ou de **mutation** nos seguintes endpoints:
- `http://127.0.0.1:5000/graphql-query`
- `http://127.0.0.1:5000/graphql-mutation`
### Exemplo de query
```
{
allPosts{
edges{
node{
title
author{
name
email
}
}
}
}
}
```
### Exemplo de mutation
```
mutation {
savePost(email:"cse.sadhan@gmail.com", title:"Title 2", body:"Blog post 2") {
post{
title
body
author{
email
}
}
}
}
```