Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gustavovalle23/food-recipe
API that brings recipes from an ingredient list
https://github.com/gustavovalle23/food-recipe
fastapi graphql pytest python sql sqlalchemy
Last synced: about 1 month ago
JSON representation
API that brings recipes from an ingredient list
- Host: GitHub
- URL: https://github.com/gustavovalle23/food-recipe
- Owner: gustavovalle23
- License: mit
- Created: 2022-08-11T03:07:27.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-11-26T05:04:15.000Z (about 2 years ago)
- Last Synced: 2023-03-05T14:44:42.432Z (almost 2 years ago)
- Topics: fastapi, graphql, pytest, python, sql, sqlalchemy
- Language: Python
- Homepage:
- Size: 340 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Food System
The Food Recipe system brings the possibility to search for recipes, but in a different way. The usual thing is to search for the name of a recipe and the system tells you what ingredients are needed and how to prepare. Here we do the opposite, you inform which ingredients you have and the system informs you which recipes you are able to make.## Avaiable queries:
```graphql
query RecipesWithIngredients {
recipesWithIngredients (ingredientIds: [1, 4, 5]) {
id
name
ingredients {
id
name
quantity
unitMeasurement
}
link
}
}query AvaiableIngredients {
availableIngredients{
id
name
quantity
unitMeasurement
}
}query AvailableRecipes {
availableRecipes {
id
name
link
ingredients {
id
name
quantity
unitMeasurement
}
}
}
```## Avaiable mutations:
```graphql
mutation CreateIngredient {
createIngredient(ingredient: {
name: "Marshmellow",
quantity: 1,
unitMeasurement: GRAM
})
}mutation CreateRecipe {
createRecipe(recipe: {
name: "Orange Pie",
link: "https://www.recipelink.com/recipecards/889_dinner_with_peaches.html"
})
}mutation AddIngredientToRecipe {
addIngredientToRecipe(recipeId: "1", ingredientIds: ["1", "3"])
}```
# To export GraphQL schema:
strawberry export-schema main:schema > schema.graphql### recipesWithIngredients used following sql query
```sql
SELECT *
FROM recipes r
WHERE r.id NOT IN (
SELECT recipe_id
FROM ingredient_recipe
WHERE ingredient_id NOT IN (10, 2, 4, 5, 1)
)
AND r.id IN (
SELECT ir.recipe_id
FROM ingredient_recipe ir
)
```To execute tests:
```shell
python app/infra/models.py
python -m pytest test -s -vv
```