An open API service indexing awesome lists of open source software.

https://github.com/fanqingsong/fastapi_strawberry_graphql_sqlalchemy


https://github.com/fanqingsong/fastapi_strawberry_graphql_sqlalchemy

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

        

Fast Api Strawberry GraphQL Async SQL Alchemy Boiler Plate


## Description

This code is a boiler plate for the implementation of GraphQL with Fast Api using Strawberry Library.
For GraphQL server we have used Strawberry.

## Features

- Production ready Python web server using Uvicorn and Gunicorn.

- Python **FastAPI** backend

- Async Connection of SQL Alchemy with POSTGRESQL DataBase.

- CRUD Operations of GraphQL using Strawberry Library.

- Written Async Unit Tests using Pytest to test GraphQL queries and mutations.

- Boiler Plate directory struture for GraphQL Python.

- Get the data only from the columns using SQL Alchmey which are specified in GraphQL Query.

- Deployment using Docker Container through Docker Compose file.

- Deployed code at specific endpoint to test GraphQL.

- Alembic migrations.

- Jenkins (continuous integration).
## Installation

To run the project in your local environment::

1. Clone the repository::
```
git clone [email protected]:fanqingsong/fastapi_strawberry_graphql_sqlalchemy.git
cd fastapi_strawberry_graphql_sqlalchemy
```
2. Create and activate a virtual environment::
```
virtualenv env -p python3
source env/bin/activate
```
3. Install requirements::
```
pip install -r requirements.txt
```
4. Run the application::
```
python main_dev.py
```
To run the project using Docker Container:

1. Clone the repository::
```
git clone [email protected]:fanqingsong/fastapi_strawberry_graphql_sqlalchemy.git
cd fastapi_strawberry_graphql_sqlalchemy
```
2. Run this command on CMD::
```
docker-compose up -d --build
```
## Usage Examples

Launch the fast api server at specified port default 5000 (open the UI at http://localhost:5000/graphql): ::

python main_dev.py

Launch using docker: ::

docker-compose up -d --build

## Tests

Test are run with *pytest*. If you are not familiar with this package you can get some more info from `their website `_.

To run the tests, from the project directory, simply::

```
$ pip install -r requirements.txt
$ python test.py
```

You should see output similar to::
```
----------- coverage: platform win32, python 3.8.8-final-0 -----------
Name Stmts Miss Cover
-------------------------------------------------------
tests\conftest.py 18 4 78%
tests\graphql\mutations.py 3 0 100%
tests\graphql\queries.py 2 0 100%
tests\graphql\test_stickynotes.py 0 0 100%
tests\graphql\test_user.py 43 0 100%
tests\load_test_env.py 4 4 0%
-------------------------------------------------------
TOTAL 70 8 89%

=================== 8 passed in 0.59s =================
```
## Migrations

To run the project in your local environment::

```
$ alembic revision --autogenerate -m "migration string"
$ alembic upgrade head
```
## License

This project is licensed under the terms of the MIT license. If you have any question about this opinionated list, do not hesitate to contact me [[email protected]](mailto:[email protected]) or open an issue on GitHub.