aws-mobile-appsync-sdk-ios icon indicating copy to clipboard operation
aws-mobile-appsync-sdk-ios copied to clipboard

Add priorities for mutation

Open larryonoff opened this issue 6 years ago • 14 comments

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.

larryonoff avatar Dec 08 '18 19:12 larryonoff

link with PR #109

larryonoff avatar Dec 08 '18 19:12 larryonoff

Tagging @undefobj to get thoughts on prioritization of the feature.

rohandubal avatar Dec 10 '18 05:12 rohandubal

@rohandubal @undefobj please note that it's already implemented in #109

larryonoff avatar Dec 10 '18 09:12 larryonoff

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.

larryonoff avatar Jan 01 '19 16:01 larryonoff

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.

palpatim avatar Jan 03 '19 16:01 palpatim

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 avatar Jan 03 '19 17:01 larryonoff

@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 avatar Apr 04 '19 07:04 btn52396

@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 avatar Apr 04 '19 07:04 larryonoff

@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 avatar Apr 04 '19 08:04 btn52396

@btn52396 I did, but priorities weren't approved and were removed in the next commit.

larryonoff avatar Apr 04 '19 08:04 larryonoff

@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 avatar Apr 04 '19 08:04 btn52396

@btn52396 could you please specify what change in AWSSQLLiteNormalizedCache.swift you're referring.

larryonoff avatar Apr 04 '19 09:04 larryonoff

@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 avatar Apr 04 '19 21:04 btn52396

@btn52396 thanks for catching and explaining. I just returned this functionality.

larryonoff avatar Apr 05 '19 10:04 larryonoff

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.

atierian avatar Dec 07 '23 20:12 atierian