You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a query with the following GraphQLEnumType.
enum FeatureClass {
person
car
cat
dog
}
When I run apollo-codegen, I get the following enum definition and it works fine.
public enum FeatureClass: String, Apollo.JSONDecodable, Apollo.JSONEncodable {
case person = "person"
case car = "car"
case cat = "cat"
case dog = "dog"
}
public var classes: [FeatureClass] {
get {
return snapshot["classes"]! as! [FeatureClass]
}
set {
snapshot.updateValue(newValue, forKey: "classes")
}
}
However, I serialise the snapshot data using JSONSerializationFormat, save it in NSUserDefault, deserialise it and access the field of the enum again, I get the following crash.
someData.classes (Crash)
Could not cast value of type 'NSTaggedPointerString' (0x110dde5c8) to 'XXX.FeatureClass' (0x106d48600)
I personally investigated the issue of this field by accessing through snapshot dictinary and found that casting the certain enum type is making the crash.
po someData.snapshot["classes"]! as! [FeatureClass] (Crash)
However, if I access the enum field as the array of enum.rawValue, it works fine.
po someData.snapshot["classes"]! as! [FeatureClass.RawValue] (Works)
Is this the expected behaviour ?.
I am using apollo-codegen 0.17.1 (not latest). I can't use the latest apollo-codegen for some enum naming issues.
Thanks in advance.
The text was updated successfully, but these errors were encountered:
I have a query with the following GraphQLEnumType.
When I run apollo-codegen, I get the following enum definition and it works fine.
However, I serialise the snapshot data using JSONSerializationFormat, save it in NSUserDefault, deserialise it and access the field of the enum again, I get the following crash.
I personally investigated the issue of this field by accessing through snapshot dictinary and found that casting the certain enum type is making the crash.
However, if I access the enum field as the array of enum.rawValue, it works fine.
Is this the expected behaviour ?.
I am using apollo-codegen 0.17.1 (not latest). I can't use the latest apollo-codegen for some enum naming issues.
Thanks in advance.
The text was updated successfully, but these errors were encountered: