Skip to content
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

Store WithReadWriteTransaction updates do not persist after app close. #234

Closed
WarSunsOfPeace opened this issue Apr 16, 2019 · 8 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@WarSunsOfPeace
Copy link

Describe the bug
Writing to the cache directly doesn't update the persistent store and does not live through app shutdown. The cache is functioning because I run another query and get results from the server then shut down the app, and then see those results using a query with the .returnCacheDataDontFetch policy.

To Reproduce
Steps to reproduce the behavior:

  1. Get Data from outside source
  2. And to cache using ApolloClient.Store.withinReadWriteTransaction.
  3. Run Query that you added data for using .returnCacheDataDontFetch cache policy.
  4. Verify Results
  5. Force Quit App
  6. Run Query from Step 3
  7. Results Not Found.

Expected behavior
I expect that updating the cache directly would also right to the persistent cache.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment(please complete the following information):

  • AppSync SDK Version: 2.10.4
  • Dependency Manager: Carthage
  • Swift Version : 5.0

Device Information (please complete the following information):

  • Device: iPhoneX and Simulators
  • iOS Version: 12.2
  • Specific to simulators: No

Additional context
Add any other context about the problem here.

@WarSunsOfPeace WarSunsOfPeace changed the title Store WithReadWriteTransaction updates to not persist after app close. Store WithReadWriteTransaction updates do not persist after app close. Apr 16, 2019
@rohandubal
Copy link
Contributor

Hello @w0mba7

Could you please answer these questions so that we could help you better?

  • Can you provide a code snippet using which we can reproduce this issue?
  • Are you checking for any errors which could have happened during the write?

Thanks,
Rohan

@rohandubal rohandubal added AppSync requesting info Further information is needed before this is actionable labels Apr 18, 2019
@WarSunsOfPeace
Copy link
Author

Here is the code that i have for writing updating the cache. I didn't see any errors in the console log and I can use the results else were in the app, they are just lost when the app quits. Is there somewhere specific I should be checking for the write erros?
let t = self.appSyncClient?.store?.withinReadWriteTransaction { transaction in try transaction.update(query: AllProductsQuery()) { (data: inout AllProductsQuery.Data) in data.allProducts = [] let cacheItems = list.compactMap({ (item) -> AllProductsQuery.Data.AllProduct? in if let id = item.id, let title = item.title { return AllProductsQuery.Data.AllProduct.init(id: id, title: title) } else { return nil } }) data.allProducts?.append(contentsOf: cacheItems) } }

@palpatim palpatim added question A question about how to use an existing feature and removed requesting info Further information is needed before this is actionable labels Apr 22, 2019
@palpatim
Copy link
Contributor

@w0mba7

We're aware of an issue with the persistent cache for apps built using Xcode 10.2. Can you verify the version of Xcode you're using? (Since you specify iOS 12.2, I'm assuming it's Xcode 10.2 or 10.2.1, but I'd like to confirm.)

@palpatim palpatim added the requesting info Further information is needed before this is actionable label Apr 22, 2019
@palpatim palpatim assigned palpatim and unassigned rohandubal Apr 22, 2019
@WarSunsOfPeace
Copy link
Author

Yes I am using Xcode 10.2.1

@palpatim
Copy link
Contributor

Thanks for the update. I believe this will be fixed when we update to SQLite.swift 0.11.6. I'll update this issue once we have that released.

@palpatim palpatim added pending-release Work is done, but issue can't be closed since the changes were not released yet bug Something isn't working and removed requesting info Further information is needed before this is actionable question A question about how to use an existing feature labels Apr 22, 2019
@WarSunsOfPeace
Copy link
Author

I just added SQLite 11.6 as a direct dependency in Carthage and I was able to force close the app and relaunch with the data.

@palpatim
Copy link
Contributor

That's great to hear. I'm going to leave this issue open until we resolve the SQLite update in the main codebase.

@palpatim palpatim added requesting info Further information is needed before this is actionable and removed pending-release Work is done, but issue can't be closed since the changes were not released yet labels Apr 24, 2019
@palpatim
Copy link
Contributor

This is fixed in 2.12.0. Please comment on that issue if you continue to see problems.

@palpatim palpatim removed the requesting info Further information is needed before this is actionable label Apr 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants