You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 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.
The text was updated successfully, but these errors were encountered:
I support this opinion as well. I can store __id somewhere to invalidate a few items (hopefully active fragment or root field) but it is hard to manage every ids I need to invalidate. I am actually surprised this is not supported... I think it can be (merely) possible to implement it by getting all data ids from internal Map (filter them with parent id) i.e.) store.__mutator.__sources[1]._records.keys() and invalidate them manually, but hard to say it is ideal.
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 liketodos(completed: Boolean)
, it can be easy to just invalidate the affected arguments (ex. onlytodos(completed: False)
andtodos(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 ascompleted: True
only).There is a line in the docs 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.The text was updated successfully, but these errors were encountered: