The vtex.search-segment-resolver
is a boilerplate that you can use for you own implementation of the segment search (TODO: add the segment documentation link).
-
Fork this project.
-
Change the
vendor
in themanifest.json
file. -
Change the
searchSegment
function in the/node/resolver/segmentSearch.ts
file. It will receive theuserEmail
as argument and must return an array of facets. Exanoke:export const queries = { searchSegment: async (_: unknown, args: SearchSegmentInput, __: Context) => { const { userEmail } = args switch (userEmail) { case 'myclient@shoes.com': return [{ key: 'category-1', value: 'shoes' }] case 'myclient@shirts.com': return [{ key: 'category-1', value: 'shirt' }] case 'myclient@hats.com': return [{ key: 'category-1', value: 'hats' }] default: return [] } }, }
3.5 If you want to call an external API, you can add a new client to the
node/clients
diredtory. -
Link/install the app on your workspace.