blitz
blitz copied to clipboard
Fix queryKeyGeneration when using invalidateQuery
Closes: #3725
What are the changes and their implications?
Bug Checklist
- [x] Fix invalidateQuery called with one param generating
{json: undefined}
as param
Feature Checklist
- [ ] Integration test added (see test docs if needed)
- [ ] Documentation added/updated (submit PR to blitzjs.com repo
canary
branch)
🦋 Changeset detected
Latest commit: 2a10e378f6f456a3e7d006392c860918b351586e
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 29 packages
Name | Type |
---|---|
@blitzjs/rpc | Patch |
blitz | Patch |
@blitzjs/next | Patch |
@blitzjs/auth | Patch |
@blitzjs/codemod | Patch |
@blitzjs/recipe-base-web | Patch |
@blitzjs/recipe-bulma | Patch |
@blitzjs/recipe-bumbag-ui | Patch |
@blitzjs/recipe-chakra-ui | Patch |
@blitzjs/recipe-emotion | Patch |
@blitzjs/recipe-gh-action-yarn-mariadb | Patch |
@blitzjs/recipe-gh-action-yarn-postgres | Patch |
@blitzjs/recipe-ghost | Patch |
@blitzjs/recipe-graphql | Patch |
@blitzjs/recipe-logrocket | Patch |
@blitzjs/recipe-material-ui | Patch |
@blitzjs/recipe-next-ui | Patch |
@blitzjs/recipe-passenger | Patch |
@blitzjs/recipe-quirrel | Patch |
@blitzjs/recipe-reflexjs | Patch |
@blitzjs/recipe-render | Patch |
@blitzjs/recipe-secureheaders | Patch |
@blitzjs/recipe-stitches | Patch |
@blitzjs/recipe-styled-components | Patch |
@blitzjs/recipe-tailwind | Patch |
@blitzjs/recipe-theme-ui | Patch |
@blitzjs/recipe-vanilla-extract | Patch |
@blitzjs/config | Patch |
@blitzjs/generator | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
@beerose
invalidateQuery(a)
if a is [queryName]
it revalidates everything regardless of arguments, while [queryName, params]
revalidates a specific params.
So the || {}
would only invalidate that if the params were {} for the query itself, so technically it would work but it wouldn't work the same way as tanstack/query itself
Actually what we want is this
useQuery(getUser, undefined) // get dummy user
useQuery(getUser, 10)
Having undefined / 10 and in that case you have
invalidateQuery(getUser) // all get user queries
invalidateQuery(getUser, undefined) // just the first one -> so dummy user
invalidateQuery(getUser, 10) // invalidate user 10
And the PR currently doesn't do that so I'll fix it now and then re-request your review
Is there a workaround for this while we wait for a release with this fix?
Hey @Zeko369, wanted to follow up on this. We were talking about adding tests. Are you still up for adding them?
@beerose unit tests for getKey and integration tests with actual invalidation 🚀 added