Skip to content

Commit

Permalink
fix: Add required block response in recipe api (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
Atralupus authored Mar 14, 2024
1 parent 63f24ff commit 504fe04
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions backend/app/Savor22b/GraphTypes/Query/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ private List<RecipeResponse> combineRecipeData()
new RecipeResponse(
recipe.ID,
recipe.Name,
recipe.RequiredBlock,
recipeIngredientComponents,
recipeFoodComponents
)
Expand Down
6 changes: 6 additions & 0 deletions backend/app/Savor22b/GraphTypes/Types/RecipeGraphType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public RecipeResponseType()
resolve: context => context.Source.Name
);

Field<IntGraphType>(
name: "required",
description: "The RequiredBlock of the recipe.",
resolve: context => context.Source.RequiredBlock
);

Field<ListGraphType<RecipeComponentType>>(
name: "ingredientIDList",
description: "The list of ingredients in the recipe.",
Expand Down
17 changes: 12 additions & 5 deletions backend/app/Savor22b/GraphTypes/Types/RecipeResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,28 @@ namespace Savor22b.GraphTypes.Types;

public class RecipeResponse
{
public int Id { get; set; }
public string Name { get; set; }
public List<RecipeComponent> IngredientList { get; set; }
public List<RecipeComponent> FoodList { get; set; }

public RecipeResponse(
int id,
string name,
int requiredBlock,
List<RecipeComponent> ingredientList,
List<RecipeComponent> foodList
)
{
Id = id;
Name = name;
RequiredBlock = requiredBlock;
IngredientList = ingredientList;
FoodList = foodList;
}

public int Id { get; set; }

public string Name { get; set; }

public int RequiredBlock { get; set; }

public List<RecipeComponent> IngredientList { get; set; }

public List<RecipeComponent> FoodList { get; set; }
}

0 comments on commit 504fe04

Please sign in to comment.