From fae67cfa774bee5a4e00798036467c06c4c2204f Mon Sep 17 00:00:00 2001 From: Alex Lelidis Date: Thu, 21 Nov 2024 18:24:57 +0100 Subject: [PATCH] load products for reviews --- examples/federation/reviews/graph/entity.resolvers.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/federation/reviews/graph/entity.resolvers.go b/examples/federation/reviews/graph/entity.resolvers.go index 213bd290b..7043d174a 100644 --- a/examples/federation/reviews/graph/entity.resolvers.go +++ b/examples/federation/reviews/graph/entity.resolvers.go @@ -13,8 +13,16 @@ import ( // FindProductByUpc is the resolver for the findProductByUpc field. func (r *entityResolver) FindProductByUpc(ctx context.Context, upc string) (*model.Product, error) { + var productReviews []*model.Review + for _, review := range reviews { + if review.Product.Upc == upc { + productReviews = append(productReviews, review) + } + } + return &model.Product{ - Upc: upc, + Upc: upc, + Reviews: productReviews, }, nil }