-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent store #43
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…c-sdk-js * 'master' of https://github.com/awslabs/aws-mobile-appsync-sdk-js: Release aws-appsync@1.0.10 Update CHANGELOG.md Update x-amz-user-agent header Release aws-appsync@1.0.9 Preserve the observer associated with an existing topic (#37) Fix AWS_IAM credentials fetching (#38)
for effect When calling `enqueueMutation` in `offline-link.js`, the operation object created by `QueryManager` does not contain the update function. See `buildOperationForLink`. To preserve the update function, we save it in `AASContext` which is included (in `context`) when building the operation
Constantly restoring apollo cache from store after writing causes issues with optimistic responses. The patches are not pruned and ultimately the appsync store does not end up with the correct data and the apollo cache is 'corrupted'. Easily reproducible by creating a mutation with a pessimistic boolean flag on optimistic response, no update function (as to not update an existing query) and no running subscription.
The problem actually occurs when we execute recordOptimisticTransaction. During an optimistic transaction on the offline-cache, the data object that backs up the cache is swapped with a recordingCache. This object is responsible for recording the data diff for the optimistic transaction. So the optimistic results are written to the recordingCache which keeps a data and recordedData set (the calculated diff). Currently after the write, the offline-cache then extracts all the data (from the data set) and sends it to the redux store. Our subscription is triggered and we call replace with the new data which calls restore on the recordingCache. So this is where the actual “corruption” happens. recordedData is returned as the patch, the transaction ends and the recordingCache is replaced by the original ObjectCache object. When our mutation result is returned from the server and we call extract to save it to the redux store we get the data + the patch.
manueliglesias
approved these changes
Feb 27, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM 🎉
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix issue with missing update function and an inconsistent appsync store