Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions client/src/graphql/recipes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import type { Recipe } from '../types/recipe';
// Query-ene henter kun den informasjonen som en komponent trenger, sånn at det sendes minst mulig data.

// Typer for svaret og variablene, sånn at typescript vet hvordan dataene ser ut.
type GetRecipesData = { recipes: Recipe[] };
type GetRecipesData = {
recipes: {
items: Recipe[];
totalCount: number;
};
};
type GetRecipesVariables = {
search?: string;
page?: number;
Expand All @@ -18,11 +23,13 @@ type GetRecipeVariables = { id: string };
export const GET_RECIPES: TypedDocumentNode<GetRecipesData,GetRecipesVariables> = gql`
query GetRecipes($search: String, $page: Int, $pageSize: Int) {
recipes(search: $search, page: $page, pageSize: $pageSize) {
totalCount
items {
id
imageUrl
title
prepTimeMinutes
servings
servings}
}
}
`;
Expand Down Expand Up @@ -62,15 +69,18 @@ export const GET_RECIPE: TypedDocumentNode<GetRecipeData, GetRecipeVariables> =
export const GET_FEATURED_RECIPES: TypedDocumentNode<GetRecipesData, GetRecipesVariables> = gql `
query GetFeaturedRecipes($page: Int, $pageSize: Int) {
recipes(page: $page, pageSize: $pageSize) {
id
title
description
prepTimeMinutes
servings
imageUrl
tags {
totalCount
items {
id
name
title
description
prepTimeMinutes
servings
imageUrl
tags {
id
name
}
}
}
}
Expand Down
Loading