query icon indicating copy to clipboard operation
query copied to clipboard

Broadcast invalidation requests

Open aldebout opened this issue 4 years ago • 9 comments

This PR allows invalidating queries in other tabs that don't exist in the current tab cache.

The use case that we have is to invalidate the preview of a document in a list when editing the document in another tab, as discussed here.

The PR in its current form deletes the current broadcastQueryClient function in favor of a class, it might be worth keeping the existing code not to completely nuke the API, even on an experimental feature. There might also be a way to achieve the same result while keeping the function but my attempts at overriding invalidateQueries were not successful.

getQueryFilters removes the extra keys from the filters because functions can't be serialized and sent on a BroadcastChannel.

aldebout avatar Aug 27 '21 03:08 aldebout

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/tanstack/react-query/58b1Vb64YBHJZf1QDRjxbQsLUxAo
✅ Preview: https://react-query-git-fork-aldebout-class-broadcast-i-1a2d57-tanstack.vercel.app

vercel[bot] avatar Aug 27 '21 03:08 vercel[bot]

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 e14c96873b93c50a154dfc06822deb0f4c675db6:

Sandbox Source
tannerlinsley/react-query: basic Configuration
tannerlinsley/react-query: basic-typescript Configuration

codesandbox-ci[bot] avatar Aug 27 '21 03:08 codesandbox-ci[bot]

could it be that your change to parseFilterArgs broke some tests?

TkDodo avatar Aug 29 '21 16:08 TkDodo

could it be that your change to parseFilterArgs broke some tests?

It looks like it indeed, it seems I forgot some keys in the pick function. What threw me off is this signature, I'll add more keys until the tests pass.

export function parseFilterArgs<
  TFilters extends QueryFilters,
  TOptions = unknown
>

aldebout avatar Aug 30 '21 15:08 aldebout

@TkDodo Anything I can do to move this forward?

aldebout avatar Sep 07 '21 12:09 aldebout

I'm sorry, I'm very unfamiliar with this plugin and how it should work, so I'll have to leave this to @tannerlinsley

TkDodo avatar Oct 31 '21 07:10 TkDodo

LGTM, but it will be a "breaking" change. But hey, that's why it's experimental, right?

tannerlinsley avatar Nov 01 '21 17:11 tannerlinsley

It will need to be brought up to date with any changes recently to get rid of the conflicts.

tannerlinsley avatar Nov 01 '21 17:11 tannerlinsley

@tannerlinsley took me some time to come back but everything should be good now :) FWIW it's been running in prod for a few months on our side, although it's admittedly a pretty niche feature so it has not seen a lot of action.

aldebout avatar Dec 21 '21 22:12 aldebout

FYI, I will close stale PRs somewhen next week. Please either address the open comments / resolve the merge conflicts or this PR will be closed. Thanks 🙏

TkDodo avatar Sep 23 '22 12:09 TkDodo