Open
Description
Description
I am updating from the AppSync SDK and using the Swift files generated by the Amplify CLI. However, I am encountering an issue where the parsing of enums fails.
public var status: HogeStatus {
get {
return snapshot["status"]! as! HogeStatus // <- fails
}
set {
snapshot.updateValue(newValue, forKey: "status")
}
}
Error:
Could not cast value of type ‘__NSCFString’ to ‘HogeStatus’.
It seems that snapshot["status"] is being interpreted as a String. In the AppSync SDK, the value is retrieved as an enum, but in Amplify, it becomes a String.
Is there any way to handle this in Amplify to avoid this issue?
In the AppSync SDK, there was logic to handle enums in GraphQLSelectionSetMapper, but I couldn't find a similar feature in Amplify.
Environments
Amplify CLI 12.13.1
Amplify 2.45.4