-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement redirect query (#1746)
## What's the purpose of this pull request? This PR adds a query to solve redirects when performing a search. In case of VTEX platform, this is solved by the IS api. ## How it works? When performing a search if a term or facet has a redirect, the value of the `redirect` field should be an URL; this can later be used to redirect the user to an internal or external URL. From VTEX admin: <img width="795" alt="Screenshot 2023-05-04 at 17 51 48" src="https://user-images.githubusercontent.com/50715158/236261672-24230b76-3f5e-4f92-8c17-53111fd65f24.png"> It get solved as: <img width="1474" alt="image" src="https://github.com/vtex/faststore/assets/67066494/4cecfa15-200b-49a0-a070-e4226f57c71e"> ## How to test it? - Run the `@faststore/api` package individually. - Browse [localhost/graphql](http://localhost:4000/graphql) - Run the redirect query with a term that is active in `/admin/search/v4/redirects/` - For storeframework, you can use the term `tech` PR related at vtex-sites: vtex-sites/nextjs.store#382 PR related 2.x: #1749 --------- Co-authored-by: beatrizmaselli <[email protected]>
- Loading branch information
1 parent
950ce98
commit d9b0ace
Showing
7 changed files
with
145 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
export const RedirectQueryTermTech = `query RedirectSearch { | ||
redirect(term: "tech") { | ||
url | ||
} | ||
} | ||
` | ||
|
||
export const redirectTermTechFetch = { | ||
info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=2&count=1&query=tech&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false', | ||
init: undefined, | ||
result: { | ||
products: [], | ||
recordsFiltered: 0, | ||
fuzzy: 'auto', | ||
operator: 'and', | ||
redirect: '/technology', | ||
translated: false, | ||
pagination: { | ||
count: 1, | ||
current: { | ||
index: 0, | ||
}, | ||
before: [], | ||
after: [], | ||
perPage: 0, | ||
next: { | ||
index: 0, | ||
}, | ||
previous: { | ||
index: 0, | ||
}, | ||
first: { | ||
index: 0, | ||
}, | ||
last: { | ||
index: 0, | ||
}, | ||
}, | ||
}, | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters