-
Notifications
You must be signed in to change notification settings - Fork 731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataDict subscript function crashes on iOS 14.4 and under #2668
Comments
Just an addendum; We do not see this crash on iOS 14.5 and higher. But we unfortunately need to support iOS 14.0 and up for the foreseeable future. |
Hmm, this seems pretty weird. I'll try replicate but may need to reach out for a sample project if I cannot get it crashing. |
@bdunay3 - confirmed, I can replicate the crash on 14.4 and lower. Thanks for the great bug report, we'll get this resolved. |
@calvincestari This might be as easy as changing the getter to: get { (_data[key] as? AnyHashable)?.base as! T } |
@bdunay3 this is now fixed and in |
Bug report
We have a value in our graph that maps to
String?
. If we send a query that has a property field with a value type ofString?
and in the response that property has anil
value, the response is parsed just fine by Apollo client. But, when we go to access that property from the generated code we get a crash in this code:In Swift 5.4 additional type safety was introduced. I also see that they started adding the plumbing to support existential types via the compiler. I believe what is happening in this code is that the Swift 5.4 runtime can deal with casting a
AnyHashable
to a concrete type more easily. But the Swift 5.3.2 runtime and lower can not.When I'm in the debugger if I try to access the value using this statement:
Then LLDB reports back the correct value of nil. But if I try to access it doing something like:
Then I get back errors from LLDB. Usually something like:
I think this code needs to be a little more robust. The force-unwrap is just opening up clients to crashes. What I would like to see is something where either this property returns a T? or maybe the the property needs to throw?
If you have suggestions on better ways to handle this from the client side, or if there are things we can do in our graph (outside of change the property to not be nilable) I would very much be open to trying them out. But ideally the code should be force unwrapping and deal with the type conversion is a safer way.
Thank you for your time and any help is appreciated.
Versions
Please fill in the versions you're currently using:
apollo-ios
SDK version: 1.0.2Steps to reproduce
Please replace this line with steps to reproduce the problem.
nil
in the returned dataThe text was updated successfully, but these errors were encountered: