Skip to content

Question: Refetching paginated resource after mutation #1548

@saaymeen

Description

@saaymeen

Hi!

I display a paginated result from useResource at one point in my app. The user can create additional items for this list in a dialog. The docs for immediate mutation updates specify pretty well how to append the result of a mutation in the current cache, for my use case however this does not work because I do not know the pagination params of the list in the create dialog. (This would be impossible to know anyway, since there can be essentially an unknown number of lists of that resource across the app)
Appending the created resource to the paginated list does make little sense, since I can't easily figure out if the new resource matches the pagination criteria. But one way to have a immediate UI update would be to refetch all useResource hooks that use the detail shape, no matter their params. invalidate and fetch only trigger a change for hooks that use the same params, is the a way to tell them to refetch for every set of params that are currently being rendered? Or am I overthinking something/am I looking at this from the wrong angle?

I could not find a discussion forum for the project, sorry for posting this question as an issue.

Kind regards

Simon

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions