Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): Handle channel as facet for search and product queries #1197

Merged
merged 7 commits into from
Mar 31, 2022

Conversation

igorbrasileiro
Copy link
Contributor

@igorbrasileiro igorbrasileiro commented Mar 29, 2022

What's the purpose of this pull request?

How it works?

How to test it?

base.store Deploy Preview

vtex-sites/base.store#428

References

@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 29, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 5c5529f:

Sandbox Source
Store UI Typescript Configuration


export const Query = {
product: async (_: unknown, { locator }: QueryProductArgs, ctx: Context) => {
// Insert channel in context for later usage
ctx.storage = {
...ctx.storage,
channel:
locator.find((facet) => facet.key === 'channel')?.value ??
ctx.storage.channel,
// TODO: Check if make sense move this parse a layer down or pass the whole parsed channel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just keep it like a string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, you mean that should maintain as a string here and move the parse to be done inside a lower layer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep like a string breaks some internal field resolvers take a look at the
https://sfj-a1d5edd--base.preview.vtex.app/office/

 ERROR

Error: Product with id 2791588 has no sellers for channel
{"regionId":"v2.1BB18CE648B5111D0933734ED83EC783","salesChannel":"1"}.
    at Object.offers
(webpack://base.store/./node_modules/@faststore/api/dist/api.esm.js?:820:13)
    at Object.field.resolve [as StoreProductoffersResolver]
(webpack://base.store/./node_modules/@envelop/core/index.js?:86:32)
    at nodeStoreProductEdgenodeResolverHandler (eval at compileQuery
(webpack://base.store/./node_modules/graphql-jit/dist/execution.js?), <anonymous>:3012:39)
    at StoreProductConnection__fieldedgesMapItemHandler.__value.then.__context.nullErrors.push._
_context.GraphQLError.line (eval at compileQuery
(webpack://base.store/./node_modules/graphql-jit/dist/execution.js?), <anonymous>:3151:9)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  locations: [ { line: 32, column: 11 } ],
  path: [ 'search', 'products', 'edges', 0, 'node', 'offers' ]
}

@igorbrasileiro igorbrasileiro marked this pull request as ready for review March 30, 2022 17:25
@igorbrasileiro igorbrasileiro requested a review from a team as a code owner March 30, 2022 17:25
@igorbrasileiro igorbrasileiro changed the title wip: feat(api): Handle channel as facet for search and product queries feat(api): Handle channel as facet for search and product queries Mar 30, 2022
@igorbrasileiro
Copy link
Contributor Author

Desconsider problems with ci/test frompull request

@igorbrasileiro igorbrasileiro merged commit 00556b1 into master Mar 31, 2022
@igorbrasileiro igorbrasileiro deleted the feat/regionid-as-facet-vtex branch March 31, 2022 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants