aws-mobile-appsync-sdk-ios
aws-mobile-appsync-sdk-ios copied to clipboard
Add priorities for mutation
Is your feature request related to a problem? Please describe. There're cases when it's not important the order of mutations executed. But currently all mutations executed sequentially and there's no way to change it.
Describe the solution you'd like A clear and concise description of what you want to happen.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Add any other context or screenshots about the feature request here.
link with PR #109
Tagging @undefobj to get thoughts on prioritization of the feature.
@rohandubal @undefobj please note that it's already implemented in #109
Some story why priorities are needed. We have one AppSync client in the app. We log analytics events via AppSync and there're ton of them. There're not so important than user actions, e.g create some object (workout, meal plan). So we had an issue when user actions are executed with a huge delay. Also we have some important logic that should be executed ASAP. Priorities helped us. In other way we had to create separate AppSync clients for specific domains.
Thanks for the use case description. We've heard from other customers that mutations that include S3 objects are another use case that would benefit from priorities.
We're evaluating this internally to come up with a cross-platform product direction and will reply on this thread as soon as we have more info.
I think it can be quite difficult to make it consistent between different platforms. It's better using concrete platform features / advantages (i.e. iOS).
@larryonoff Did you end up implementing the priority queue in your app? I really need to use a priority queue and am thinking of using your priority queue code on my own fork of AppSync but am wary that it may be code breaking and a headache to resolve in the future if I wanted to use future versions of AppSync.
@palpatim Is there any update on the decision for the products direction regarding this issue?
@btn52396 I did it even several times, but AWS team wants something uniform between different platforms. I don't agree with statements, but this not what is possible since languages foundations are different (e.g. Swift, JavaScript).
Please note that the branch is based on AppSync version 2.9.*, since the latest AppSync version has cache changes that just crashes our app due to iOS memory overload.
Please see my branch that our team uses https://github.com/larryonoff/aws-mobile-appsync-sdk-ios/tree/mutation-priorities
@larryonoff I noticed that in your original PR #109 you modified AWSSQLLiteNormalizedCache.swift adding code for the priority queue but in your branch you didn't. Was that not necessary?
@btn52396 I did, but priorities weren't approved and were removed in the next commit.
@larryonoff I know it wasn't approved in the master branch but in your branch that your team uses https://github.com/larryonoff/aws-mobile-appsync-sdk-ios/commit/d6da50baf94d8997dd33616f004cb6b498b328a4 you didn't modify AWSSQLLiteNormalizedCache.swift like you did in PR #109
Basically the priority for the mutations in your branch isn't going to be persistent since you didn't save it to the cache
@btn52396 could you please specify what change in AWSSQLLiteNormalizedCache.swift
you're referring.
@larryonoff
More specifically it's in the AWSMutationCache class. Changes like do { try db.run(mutationRecords.addColumn(priority)) } catch {}
to create a priority column and priority <- record.priority?.rawValue
to save the priority.
My understanding is that in your PR to the master branch from fix-offline-mutation https://github.com/larryonoff/aws-mobile-appsync-sdk-ios/tree/fix-offline-mutation/AWSAppSyncClient you saved the queue priority of each mutation to the persistent cache. In add-mutation-priorities https://github.com/larryonoff/aws-mobile-appsync-sdk-ios/tree/add-mutation-priorities which is the branch that your team uses, it doesn't seem like the priority is saved at all. If the user closes your app and restarts it, the correct priority wouldn't be pulled up.
@btn52396 thanks for catching and explaining. I just returned this functionality.
Thank you for opening this issue. AWS AppSync SDK for iOS entered maintenance mode in September 2023 and will receive no further updates as of September 2024.
Please use Amplify Swift going forward. For information on upgrading to Amplify Swift, refer to the Upgrade from AppSync SDK documentation.