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