Describe the bug
I am executing a query that updates creates a calendar event. As a result I am getting back that event instance and adding it to the list via an updater. This far everything works great.
However, creating a event may also add other events in the background that are not immediately returned (think recurring events). So what I want to do is:
- add the event that is returned to the calendar immediately
- invalidate the cache to refetch the events in the background so other events are eventually added
Now I have the following updater:
createCalendarEvent(result, args, cache) {
if (result.createCalendarEvent.calendarEventInstance) {
cache
.inspectFields("Query")
.filter((field) => field.fieldName === "calendarEvents")
.forEach((field) => {
const items = cache.resolve("Query", field.fieldName, field.arguments);
if (Array.isArray(items)) {
cache.link("Query", field.fieldName, field.arguments, [...items, result.createCalendarEvent.calendarEventInstance]);
}
// cache.invalidate("Query", field.fieldName, field.arguments); <-- Adding this breaks the update
});
}
},
As soon as I add the invalidate in the updater, the manual updates are no longer visible and the event does not get added until the refetch completes resulting in flashing of the UI.
In my opinion this should work but if that behaviour is on purpose please advice on how else this should be solved.
(I wanted to create a repro but the Postgres db for https://trygql.formidable.dev/ is down. If needed I can provide one later when its up again)
Reproduction
See description
Urql version
"urql": "^4.0.7"
"@urql/exchange-graphcache": "^7.0.2",
Validations
Describe the bug
I am executing a query that updates creates a calendar event. As a result I am getting back that event instance and adding it to the list via an updater. This far everything works great.
However, creating a event may also add other events in the background that are not immediately returned (think recurring events). So what I want to do is:
Now I have the following updater:
As soon as I add the invalidate in the updater, the manual updates are no longer visible and the event does not get added until the refetch completes resulting in flashing of the UI.
In my opinion this should work but if that behaviour is on purpose please advice on how else this should be solved.
(I wanted to create a repro but the Postgres db for https://trygql.formidable.dev/ is down. If needed I can provide one later when its up again)
Reproduction
See description
Urql version
"urql": "^4.0.7"
"@urql/exchange-graphcache": "^7.0.2",
Validations