Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kristiankjerstad/cooking-recipes-backend
https://github.com/kristiankjerstad/cooking-recipes-backend
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/kristiankjerstad/cooking-recipes-backend
- Owner: KristianKjerstad
- Created: 2024-06-19T12:40:45.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-06-21T10:20:35.000Z (5 months ago)
- Last Synced: 2024-06-22T22:21:08.416Z (5 months ago)
- Language: Go
- Size: 20.3 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Get started
* Make sure you have installed [air](https://github.com/air-verse/air) and [Go](https://go.dev/)To start the app:
1. Start the mongo db server using docker-compose: in the terminal run `docker-compose up --build`
2. go to the terminal and enter `air`.
(Alternatively the app can be started using `go run server.go`)A GraphQL playground will now start at `localhost:8060`.
## Example Graph QL queries
```GraphQL
mutation AddDog {
createDog(input: {name: "x", isGoodBoi: true}) {
_id
name
isGoodBoi
}
}query AllDogs {
dogs {
name
_id
isGoodBoi
}
}query getDog {
dog(_id:"6672e1fc003309c534c5ff34") {
name
_id
isGoodBoi
}
}mutation CreateRecipe{
createRecipe(input:{
name: "vodka redbull",
description:"a drink",
category:DRINK,
steps: ["get ingredients", "make"],
ingredients:[{name:"vodka", quantity:20, unit:"ml"},{name:"redbull", quantity:20, unit:"ml"}]
}) {
_id
}
}query GetRecipe{
recipe(_id:"6673ec1c3f75e1774098f227"){
name
description
ingredients{name quantity unit}
steps
category
}
}query AllRecipes{
recipes{
name
description
ingredients{name quantity unit}
steps
category
}
}mutation delete{
deleteRecipe(_id:"ObjectID('6673ec373f75e1774098f229')")
}mutation updateRecipe{
updateRecipe(input:
{
_id: "6673ec393f75e1774098f232"
name:"sdf"
description:"asdf"
category:DRINK
steps:["123", "2434"]
ingredients:[{_id:"123", name:"x", quantity:22, unit:"ml"}]
}
){
name
}
}
```## Modify the code
The Go code related to Graph QL is autogenerated. After making changes to the GraphQL schema in graph/schema.graphqls, open the terminal and run the command `go run github.com/99designs/gqlgen generate`.
The setup is based on [this guide](https://www.howtographql.com/graphql-go/1-getting-started/).