Jcparkyn / phetch

A small Blazor library for handling async query state, in the style of React Query
https://jcparkyn.github.io/phetch/
MIT License
46 stars 2 forks source link

Expose ResetQueries and UpdateQueries methods from UseEndpointInfinite #10

Open Paxol opened 2 months ago

Paxol commented 2 months ago

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.

Jcparkyn commented 1 month ago

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?

Paxol commented 1 month ago

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.

Jcparkyn commented 1 month ago

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?