Description of changes:
As part of working around an issue allowing optimistic updates of query results that haven't been retrieved from the service, @palpatim introduced code to pre-populate an empty table with an empty QUERY_ROOT, resolving the issue. However the issue resurfaces if at any point the caches are cleared, as the table is not then repopulated with the empty QUERY_ROOT.
So if, for example, a user installs an app for the first time and log into an account backed by AWS App Sync, the existing workaround correctly ensures that optimistic updates don't fail when the underlying query results have not been fetched from the service, but if that user were to sign out (causing the caches to be cleared) and then into another account, the workaround is no longer in place, and optimistic updates will fail.
This PR introduces changes to repopulate the cache with the empty QUERY_ROOT immediately after clearing it, thereby ensuring that optimistic updates do not fail after calling clearCaches(). The requisite tests have also been updated to showcase the issue, and show that it is resolved.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Issue #, if available:
92 (kinda?)
Description of changes: As part of working around an issue allowing optimistic updates of query results that haven't been retrieved from the service, @palpatim introduced code to pre-populate an empty table with an empty QUERY_ROOT, resolving the issue. However the issue resurfaces if at any point the caches are cleared, as the table is not then repopulated with the empty QUERY_ROOT.
So if, for example, a user installs an app for the first time and log into an account backed by AWS App Sync, the existing workaround correctly ensures that optimistic updates don't fail when the underlying query results have not been fetched from the service, but if that user were to sign out (causing the caches to be cleared) and then into another account, the workaround is no longer in place, and optimistic updates will fail.
This PR introduces changes to repopulate the cache with the empty QUERY_ROOT immediately after clearing it, thereby ensuring that optimistic updates do not fail after calling
clearCaches()
. The requisite tests have also been updated to showcase the issue, and show that it is resolved.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.