From 1aea03366a92d4d319283b4d5a497c1144338c2a Mon Sep 17 00:00:00 2001 From: Rodrigo Tadeu <49077396+RodrigoTadeuF@users.noreply.github.com> Date: Thu, 3 Aug 2023 09:05:37 -0300 Subject: [PATCH] Adding additionalInfo to the product query (#654) #### What problem is this solving? For the KitchenAid store they need a new field on the search query named additional info, this comes from the pricing API and will help them creating a new component to the store. #### How to test it? [Workspace](https://rfonseca--vtexspain.myvtex.com/admin/graphql-ide) #### How does this PR make you feel? [:link:](http://giphy.com/) ![](https://media.giphy.com/media/pWO49XP9L7TxbgQVib/giphy.gif) --------- Co-authored-by: Maira Bello --- CHANGELOG.md | 3 +++ graphql/types/Product.graphql | 9 +++++++++ node/resolvers/profile/services.ts | 2 +- node/typings/Checkout.ts | 4 ++++ node/utils/simulation.ts | 10 +++++++++- 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7fa3a04..4b868bbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Added +- `additionalInfo` to `product` query. + ## [2.166.1] - 2023-08-03 ### Fixed diff --git a/graphql/types/Product.graphql b/graphql/types/Product.graphql index 0efbb57c..b360396f 100644 --- a/graphql/types/Product.graphql +++ b/graphql/types/Product.graphql @@ -266,6 +266,11 @@ type GeneralValueTeaser { value: String } +type AdditionalInfo { + key: String + value: String +} + type Teaser { name: String generalValues: [GeneralValueTeaser] @@ -281,6 +286,10 @@ type Discount { Discount name """ name: String + """ + Additional Info + """ + additionalInfo: [AdditionalInfo] } type DeliverySlaSamples { diff --git a/node/resolvers/profile/services.ts b/node/resolvers/profile/services.ts index a4f66016..7fd6bb49 100644 --- a/node/resolvers/profile/services.ts +++ b/node/resolvers/profile/services.ts @@ -214,7 +214,7 @@ export async function saveAddress( currentProfile, context ) - + return currentAddresses.find( (address: Address) => address.addressName === newId ) as Address diff --git a/node/typings/Checkout.ts b/node/typings/Checkout.ts index 8eaca414..2fc49ea2 100644 --- a/node/typings/Checkout.ts +++ b/node/typings/Checkout.ts @@ -371,6 +371,10 @@ interface RatesAndBenefitsData { name: string featured: boolean description: string + additionalInfo?: { + key: string + value: string + } }> teaser: Array<{ featured: boolean diff --git a/node/utils/simulation.ts b/node/utils/simulation.ts index b328ff96..7b81de30 100644 --- a/node/utils/simulation.ts +++ b/node/utils/simulation.ts @@ -74,7 +74,9 @@ export const orderFormItemToSeller = ( const [logisticsInfo] = orderFormItem.logisticsInfo - const sellingPrice = orderFormItem.priceDefinition?.calculatedSellingPrice ?? orderFormItem.sellingPrice + const sellingPrice = + orderFormItem.priceDefinition?.calculatedSellingPrice ?? + orderFormItem.sellingPrice const { price } = orderFormItem @@ -161,6 +163,12 @@ const getDiscountHighLights = (ratesAndBenefitsData: RatesAndBenefitsData) => { .map((rateAndBenefitsIdentifier: any) => ({ 'k__BackingField': rateAndBenefitsIdentifier.name, ...rateAndBenefitsIdentifier, + additionalInfo: Object.keys( + rateAndBenefitsIdentifier.additionalInfo ?? {} + ).map((objectKey: string) => ({ + key: objectKey, + value: rateAndBenefitsIdentifier.additionalInfo[objectKey], + })), })) }