aws-mobile-appsync-sdk-ios
aws-mobile-appsync-sdk-ios copied to clipboard
Make AWSAppSyncOfflineMutationDelegate useful
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)
AWSAnyMutationshould conformMutationCachable.AWSAnyMutationshould be clean version ofAWSAppSyncMutationRecord, which has some unnecessary properties.AWSAppSyncOfflineMutationDelegatewill notify withAWSAnyMutation, instead of current properties.- 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.
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.
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 & ...
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.