Support invalidating linked records with any combination of arguments
- Dominant language
- Rust
- Stars
- 19k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
## Context
I need to invalidate an edge (linked record, not a connection for now) for all combinations of filters upon the user creating a new instance of the item. For example, the user might create a new "TodoItem" and I want to update/invalidate the edge `todos: [TodoItem]`. For simple filters like `todos(completed: Boolean)`, it can be easy to just invalidate the affected arguments (ex. only `todos(completed: False)` and `todos(completed: Null)` need to be updated). As more filters are added this no longer becomes sustainable, especially when arbitrary user input is added (for example searchString).
## Proposed Fix
For fields with complex filters, manually updating the store via updaters/connections is not really feasible. I'd like an API within the updater where I could do `root.invalidLinkedRecord("todos")` to invalidate all combinations of arguments (perhaps with the ability to target a subset such as `completed: True` only).
There is a [line in the docs](https://relay.dev/docs/guided-tour/list-data/updating-connections/#connection-identity-with-filters) about this which says "An easier API alternative to manage multiple connections with multiple filter values is still pending", so it seems like this is a known gap, but at least having some tracking of the issue seems helpful still.
## Workarounds
Currently, the only workaround I see is to invalidate the parent object (ex. `root.invalidateRecord()`), which is dramatically overkill. I also started a discussion in the Discord around this, but it seemed like others ran into similar trouble and didn't have any workaround either.
Contributor guide
Assessment
This issue has not been assessed yet.