Skip to content

bhavberi/FastAPI-Graphql-Strawberry-Mongodb-Template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI Strawberry-graphql MongoDB Integrated Template/Boilerplate Code 🚀

⚖️ GitHub License

Template repository for a Service using FastAPI + Strawberry-Graphql + MongoDB.

Contains example code for various variations of queries, mutations, types and models, for further reference and easy coding...
Check out Sample entities, for reference.

You can add multiple services by duplicating the template folder and its corresponding entry in the docker-compose.yml file. Create new services based on these copies.


How to use 📝

  1. Click the green Use this template button on the top right to create a new repository in the personal account for the service.
  2. Clone the newly created repository to make changes and push.
  3. Copy .env file (Make changes in it as required):
cp .example.env .env
  1. Build and spin up all services:
docker compose up --build -d
  1. Check out
localhost:80
  1. To stop, press Ctrl + C

Example Requests

# Create document
curl -X 'POST' \
  'http://localhost:80/graphql' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{"query": "mutation{sampleMutationOne(sampleInput: {attribute2: \"hi\", email: \"me@gmail.com\", name: \"test\"}) {name}}"}'

# Get documents
curl -X 'POST' \
  'http://localhost:80/graphql' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{"query": "query{sampleQueryTwo{attribute1, name}}"}'

This code was referred from the template code (Private Repository in Clubs-Council-IIITH Organisation) by @bhavberi, @ek234 and @v15hv4.


GitHub Code size in bytes