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

Make AWSAppSyncOfflineMutationDelegate useful

Open larryonoff opened this issue 6 years ago • 2 comments
trafficstars

Is your feature request related to a problem? Please describe.

See AWSAppSyncOfflineMutationDelegate definition.

public protocol AWSAppSyncOfflineMutationDelegate {
    func mutationCallback(recordIdentifier: String, operationString: String, snapshot: Snapshot?, error: Error?)
}

recordIdentifier: String is generated inside the framework and no-one outside framework knows that this identifier associated with this mutation. So the only way of identifying mutation is operationString or snapshot. But in this case strong GraphQL typing doesn't make sense.

Describe the solution you'd like

Introduce protocol like

public protocol MutationCachable {
  var mutationIdentifier: String { get }
}

with default implementation

extension MutationCachable {
  public var mutationIdentifier: String { return UUID().uuidString }
}

As an additional option AWSAnyMutation can be introduced which will replace AWSAppSyncMutationRecord. (don't know yet what properties should it has)

  1. AWSAnyMutation should conform MutationCachable.
  2. AWSAnyMutation should be clean version of AWSAppSyncMutationRecord, which has some unnecessary properties.
  3. AWSAppSyncOfflineMutationDelegate will notify with AWSAnyMutation, instead of current properties.
  4. Extend AWSAppSyncOfflineMutationDelegate, i.e.
protocol AWSAppSyncOfflineMutationDelegate: class {
  fun appSyncClient(_ appSyncClient: AWSAppSyncClient, willPerform mutation: AWSAnyMutation)
  fun appSyncClient(_ appSyncClient: AWSAppSyncClient, didPerform mutation: AWSAnyMutation, error: Error?)
}

Describe alternatives you've considered Don't have alternatives yet.

larryonoff avatar Jan 03 '19 10:01 larryonoff

Hi @larryonoff,

Thanks for the proposal. Based on this and our conversation on your other PR, this seems like a good proposal. I'll add it to our backlog as a feature request and likely pick it up with some of the mutation cleanup work I'll be doing over the next couple of weeks.

I'm not sure about the AnyMutation, both in terms of the naming and the use cases we want to support with it, but I agree that at least the identifier API can be improved.

palpatim avatar Jan 03 '19 15:01 palpatim

I also have doubts about AnyMutation, but I still find advantages. AWSAppSyncOfflineMutationDelegate events will remain the same in case of new parameters.

AnyMutation can be easily replaces with protocols composition, e.g. protocol IDontKnowHowToNameMutation = MutationCachable & MutationProtocol & ...

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