-
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
Mock that contains an array of Union type crashes on access #3023
Comments
Definitely looks like a bug! Thanks for bringing it to our attention. We'll add this to our list of fixes to be prioritized for coming patch releases. |
Thanks @AnthonyMDev, please let me know if you need any extra information. |
I found similar issue, although mine happens with mocking inline fragments. It all narrows down to not be able to cast |
The fix for this has been merged into main and will go out with our next patch release. |
@BobaFetters do you know if there are any plans for a patch release/minor release version soon that would contain #3089? We believe that's the final blocker that will allow us to update from our current version of 1.1.2 and get some of the solid performance improvements that shipped in 1.2.0 |
We had some other things slated for a patch, but I think they won't be ready for release for long than I anticipated, so maybe we should just release a 1.3.1 patch with this fix in it. |
That would definitely be appreciated on our side |
This is now available in the latest release |
Summary
Hey folks,
I'm unsure if this is a problem of us "holding it wrong" or something that is an issue, so we appreciate any comments or advice.
We have an issue where after migrating from version 1.1.2 to 1.2.0 of Apollo, we see crashes when accessing specific values on mocks.
These crashes always occur when accessing properties that have a type that is an array of a union type. We do not see similar crashes when accessing array properties that use a solid type, only those that are part of a union.
Version
1.2.0
Steps to reproduce the behavior
In our schema we have a union type called UILine, defined as the following in our generated code:
Multiple types utilise this union type, often as an array. An example of this is a UICard type.
I don't know if this matters, but the UICard type is also part of a Union.
For the UICard type the codegen step creates this Mock object (I've removed all other properties for brevity):
Also generated are these Mock objects:
These are used to attempt to create a Mock and then instantiate our
UiBlockFields
fragment.This leads to a crash on this final line, with the actual error occurring here:
Something I did find when attempting to debug this was that in the Mock init, when the
_set(_:,for:)
function is called, the(value as? AnyHashable)
always resolves to nil.Logs
Anything else?
No response
The text was updated successfully, but these errors were encountered: