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(ktabledata): fetcher cache key should respect fetcher params #2531

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Justineo
Copy link
Contributor

Summary

Fetcher cache key should reflect fetcher params.

Copy link

netlify bot commented Nov 28, 2024

Deploy Preview for kongponents-sandbox ready!

Name Link
🔨 Latest commit b146bb1
🔍 Latest deploy log https://app.netlify.com/sites/kongponents-sandbox/deploys/674e949085c2960008314232
😎 Deploy Preview https://deploy-preview-2531--kongponents-sandbox.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Justineo Justineo changed the title Fix/fetcher cache key fix(ktabledata): fetcher cache key should respect fetcher params Nov 28, 2024
Copy link

netlify bot commented Nov 28, 2024

Deploy Preview for kongponents ready!

Name Link
🔨 Latest commit b146bb1
🔍 Latest deploy log https://app.netlify.com/sites/kongponents/deploys/674e9490dc89ca0008528c14
😎 Deploy Preview https://deploy-preview-2531--kongponents.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

.should('returned', { data: [{ query: '' }] })
// fetcher should not be called as this state is already cached
cy.get('@fetcher', { timeout: 1000 })
.should('have.callCount', 2) // fetcher's 3rd call
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.should('have.callCount', 2) // fetcher's 3rd call
.should('have.callCount', 2) // fetcher's 2nd call

@@ -767,19 +768,20 @@ describe('KTableData', () => {
cy.get('.table tbody').find('tr').should('have.length', 2)
cy.get('.table tbody').should('contain.text', 'row10')
cy.get('@fetcher')
.should('have.callCount', 3)
// TODO: Investigate why fetcher is called twice here
Copy link
Contributor

Choose a reason for hiding this comment

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

I did some debugging and it turns out when switching to next page, besides the request fired by swrv triggered by the change of fetcherParams, this line watch([query, page, pageSize], async (newData, oldData) => in KTableData already implements the debounced refetch strategy when any of query, page, pageSize is changing. I think you can either exclude these params from identifierKey or remove the current watcher of these params by replacing its functionality with swrv

@kongponents-bot
Copy link
Collaborator

Preview package from this PR in consuming application

In consuming application project install preview version of kongponents generated by this PR:

@kong/kongponents@pr-2531

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