Skip to content

Commit

Permalink
update response
Browse files Browse the repository at this point in the history
  • Loading branch information
beatrizmaselli committed May 9, 2023
1 parent ebbd814 commit 9bed9aa
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
13 changes: 11 additions & 2 deletions @generated/graphql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ export type Query = {
/** Returns the details of a product based on the specified locator. */
product: StoreProduct
/** Returns if there's a redirect for a search. */
redirect: Maybe<Scalars['String']>
redirect: Maybe<StoreRedirect>
/** Returns the result of a product, facet, or suggestion search. */
search: StoreSearchResult
/** Returns information about shipping simulation. */
Expand Down Expand Up @@ -795,6 +795,15 @@ export type StorePropertyValue = {
valueReference: Scalars['String']
}

/**
* Redirect informations, including url returned by the query.
* https://schema.org/Thing
*/
export type StoreRedirect = {
/** URL to redirect */
url: Maybe<Scalars['String']>
}

/** Information of a given review. */
export type StoreReview = {
/** Review author. */
Expand Down Expand Up @@ -985,7 +994,7 @@ export type ProductGalleryQueryQueryVariables = Exact<{
}>

export type ProductGalleryQueryQuery = {
redirect: string | null
redirect: { url: string | null } | null
search: {
products: { pageInfo: { totalCount: number } }
facets: Array<
Expand Down
2 changes: 1 addition & 1 deletion @generated/graphql/persisted.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ProductGalleryQuery": "query ProductGalleryQuery($first: Int!, $after: String!, $sort: StoreSort!, $term: String!, $selectedFacets: [IStoreSelectedFacet!]!) {\n redirect(term: $term, selectedFacets: $selectedFacets)\n search(\n first: $first\n after: $after\n sort: $sort\n term: $term\n selectedFacets: $selectedFacets\n ) {\n products {\n pageInfo {\n totalCount\n }\n }\n facets {\n ... on StoreFacetRange {\n key\n label\n min {\n selected\n absolute\n }\n max {\n selected\n absolute\n }\n __typename\n }\n ... on StoreFacetBoolean {\n key\n label\n values {\n label\n value\n selected\n quantity\n }\n __typename\n }\n }\n metadata {\n isTermMisspelled\n logicalOperator\n }\n }\n}\n",
"ProductGalleryQuery": "query ProductGalleryQuery($first: Int!, $after: String!, $sort: StoreSort!, $term: String!, $selectedFacets: [IStoreSelectedFacet!]!) {\n redirect(term: $term, selectedFacets: $selectedFacets) {\n url\n }\n search(\n first: $first\n after: $after\n sort: $sort\n term: $term\n selectedFacets: $selectedFacets\n ) {\n products {\n pageInfo {\n totalCount\n }\n }\n facets {\n ... on StoreFacetRange {\n key\n label\n min {\n selected\n absolute\n }\n max {\n selected\n absolute\n }\n __typename\n }\n ... on StoreFacetBoolean {\n key\n label\n values {\n label\n value\n selected\n quantity\n }\n __typename\n }\n }\n metadata {\n isTermMisspelled\n logicalOperator\n }\n }\n}\n",
"ServerCollectionPageQuery": "query ServerCollectionPageQuery($slug: String!) {\n collection(slug: $slug) {\n seo {\n title\n description\n }\n breadcrumbList {\n itemListElement {\n item\n name\n position\n }\n }\n meta {\n selectedFacets {\n key\n value\n }\n }\n }\n}\n",
"ServerProductPageQuery": "query ServerProductPageQuery($slug: String!) {\n product(locator: [{key: \"slug\", value: $slug}]) {\n id: productID\n seo {\n title\n description\n canonical\n }\n brand {\n name\n }\n sku\n gtin\n name\n description\n releaseDate\n breadcrumbList {\n itemListElement {\n item\n name\n position\n }\n }\n image {\n url\n alternateName\n }\n offers {\n lowPrice\n highPrice\n priceCurrency\n offers {\n availability\n price\n priceValidUntil\n priceCurrency\n itemCondition\n seller {\n identifier\n }\n listPrice\n }\n }\n isVariantOf {\n productGroupID\n name\n skuVariants {\n activeVariations\n slugsMap(dominantVariantName: \"Color\")\n availableVariations(dominantVariantName: \"Color\")\n }\n }\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n}\n",
"ValidateCartMutation": "mutation ValidateCartMutation($cart: IStoreCart!, $session: IStoreSession!) {\n validateCart(cart: $cart, session: $session) {\n order {\n orderNumber\n acceptedOffer {\n seller {\n identifier\n }\n quantity\n price\n listPrice\n itemOffered {\n sku\n name\n image {\n url\n alternateName\n }\n brand {\n name\n }\n isVariantOf {\n productGroupID\n name\n }\n gtin\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n }\n }\n messages {\n text\n status\n }\n }\n}\n",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@envelop/graphql-jit": "^1.1.1",
"@envelop/parser-cache": "^2.2.0",
"@envelop/validation-cache": "^2.2.0",
"@faststore/api": "https://pkg.csb.dev/vtex/faststore/commit/4c537062/@faststore/api",
"@faststore/api": "https://pkg.csb.dev/vtex/faststore/commit/881ee90a/@faststore/api",
"@faststore/graphql-utils": "^1.11.8",
"@faststore/sdk": "^1.11.8",
"@faststore/ui": "^1.12.23",
Expand Down
4 changes: 2 additions & 2 deletions src/components/sections/ProductGallery/ProductGallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ function ProductGallery({ title, searchTerm }: Props) {
const facets = useDelayedFacets(data)
const totalCount = data?.search.products.pageInfo.totalCount ?? 0
const { next, prev } = useDelayedPagination(totalCount)
const redirect = data?.redirect
const urlRedirect = data?.redirect?.url

// check for a redirect
redirect && router.push(redirect)
urlRedirect && router.push(urlRedirect)

useProductsPrefetch(prev ? prev.cursor : null)
useProductsPrefetch(next ? next.cursor : null)
Expand Down
4 changes: 3 additions & 1 deletion src/components/sections/ProductGallery/useGalleryQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export const query = gql`
$term: String!
$selectedFacets: [IStoreSelectedFacet!]!
) {
redirect(term: $term, selectedFacets: $selectedFacets)
redirect(term: $term, selectedFacets: $selectedFacets) {
url
}
search(
first: $first
after: $after
Expand Down
5 changes: 2 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1322,10 +1322,9 @@
minimatch "^3.0.4"
strip-json-comments "^3.1.1"


"@faststore/api@https://pkg.csb.dev/vtex/faststore/commit/4c537062/@faststore/api":
"@faststore/api@https://pkg.csb.dev/vtex/faststore/commit/881ee90a/@faststore/api":
version "1.12.40"
resolved "https://pkg.csb.dev/vtex/faststore/commit/4c537062/@faststore/api#0335baef8ce0c5a6f15fee0bc9fd1f30e8bfaa15"
resolved "https://pkg.csb.dev/vtex/faststore/commit/881ee90a/@faststore/api#903c7677c7d461a91169cd5a810784649408c36d"
dependencies:
"@graphql-tools/schema" "^8.2.0"
"@rollup/plugin-graphql" "^1.0.0"
Expand Down

0 comments on commit 9bed9aa

Please sign in to comment.