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

fix(gatsby-source-vtex): page size #799

Merged
merged 5 commits into from
Jul 1, 2021
Merged

fix(gatsby-source-vtex): page size #799

merged 5 commits into from
Jul 1, 2021

Conversation

tlgimenes
Copy link
Contributor

What's the purpose of this pull request?

Fixes 404 errors while fetching products. Also, adds an option to fetch less products for testing purposes

How it works?

When we made builds on carrefourbrfood, we got a 404. This is because we were fetching too much products at once. Decreasing the number of products per fetch should solve this problem.

Also, this plugin adds a minProducts option to set the minimum amount of products to be fetched. This can help developing since we can fetch less products on "dev mode" and make a full build in production.

@tlgimenes tlgimenes requested a review from a team as a code owner July 1, 2021 11:55
@netlify
Copy link

netlify bot commented Jul 1, 2021

✔️ Deploy Preview for storeui ready!

🔨 Explore the source changes: 19f38f6

🔍 Inspect the deploy log: https://app.netlify.com/sites/storeui/deploys/60ddb1304bb55b0007cba3dd

😎 Browse the preview: https://deploy-preview-799--storeui.netlify.app

@tlgimenes tlgimenes changed the title fix: page size fix(@vtex/gatsby-source-vtex): page size Jul 1, 2021
@tlgimenes tlgimenes changed the title fix(@vtex/gatsby-source-vtex): page size fix(gatsby-source-vtex): page size Jul 1, 2021
@tlgimenes tlgimenes added this to the Gatsby Incremental Builds milestone Jul 1, 2021
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 1, 2021

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 19f38f6:

Sandbox Source
Store UI Typescript Configuration

Co-authored-by: Emerson Laurentino <emersonlaurentino@hotmail.com>
start: () => ({
// Our search is inclusive, so 0 -> PAGE_SIZE - 1 fetches PAGE_SIZE items
variables: { from: 0, to: PAGE_SIZE - 1 },
hasNextPage: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it always true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we set this to false we will never reach page 2. Setting this to true makes us fetch at least page 2 and check if we do have more pages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This works when we have less than PAGE_SIZE products as well. An example is storecomponents account that has 50-ish products

Copy link
Member

@emersonlaurentino emersonlaurentino left a comment

Choose a reason for hiding this comment

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

LGTM

Co-authored-by: Larícia Mota <lmmc2@cin.ufpe.br>
@tlgimenes tlgimenes merged commit 03b4b61 into master Jul 1, 2021
@tlgimenes tlgimenes deleted the fix/page-size branch July 1, 2021 12:22
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.

3 participants