phetch icon indicating copy to clipboard operation
phetch copied to clipboard

Expose ResetQueries and UpdateQueries methods from UseEndpointInfinite

Open Paxol opened this issue 1 year ago • 1 comments

It would be useful to enable the parent component to refetch queries under specific conditions. This could be achieved by making the UpdateQueries method public, allowing the parent component to hold a reference to UseEndpointInfinite (via @ref) and trigger the update when needed.

Paxol avatar Sep 19 '24 07:09 Paxol

I've somewhat considered this in the past, but I'm hesitant because it goes against the normal dataflow patterns in Blazor, React, etc. ("data down, actions up"). If there's a really compelling use-case I'd consider it, but can you achieve what you want using the existing Invalidate/InvalidateAll/InvalidateWhere methods on Endpoint?

Jcparkyn avatar Sep 23 '24 10:09 Jcparkyn

Maybe the missing piece is something like the queryKey in TanStack Query, that could be added to the QueryOptions class. Some type of "tag" could also be added in the query args, and than invalidate the query with InvalidateWhere, but seams less elegant to me.

Paxol avatar Oct 01 '24 14:10 Paxol

I think you can already do everything you could do with query keys just by using args here? IMO there's not much practical difference between adding a dummy arg in Phetch and adding an extra value to the query key in Tanstack - but I suspect InvalidateAll is actually what you'd want most of the time. Can you give a more specific example of the use case?

Jcparkyn avatar Oct 03 '24 01:10 Jcparkyn