-
Notifications
You must be signed in to change notification settings - Fork 722
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
Crash in test code working with nullable enums #2813
Comments
Hi @samus, I think you're running into the same issue we've had reported in #2686. Is your project/dependency configuration the same as what I've described in #2686 (comment)? Using an Xcode-based project with Apollo as an SPM dependency with the test mocks being generated into the SPM schema module? |
Yes it is very similar. I have an app target and a business logic framework that are defined in Xcode with the framework and framework tests referencing the schema SPM defined framework. Now that I scrolled further back in the log I also see the class implemented in two modules warning. You mentioned the only way you found around that was to make the schema framework dynamic. Is that recommended? |
I suspect you have the test mocks being generated into the schema module too? If so you could try generate them to an absolute path outside of the generated SPM module. They will need to be added manually to you test target but that may remove part of the dependency problem; I haven't tried this yet.
It can affect app size and startup performance mainly; there are tradeoffs to this approach and it's something that should be considered per project. This article does a good job of deep diving into the differences. I wouldn't just jump to the conclusion that it's bad though. Best if you can measure the tradeoffs and make a decision based on data. |
Following up on this after a lot of project restructuring. I'm able to use the mocks without crashing now. My project structure is an Xcode project with an App target. The app target depends on a Swift Package containing the business logic. That package defines a business logic static lib and a test target. The business logic package depends on an app graphql schema package that includes generated test mocks. The tests in the business logic package are able to use the test mocks without any trouble using this structure. I did have to extract my protocols into a separate package that is a dynamic library in order to eliminate the last of the duplicate symbols. The final structure looks something like: App |
Thank you for circling back and helping with that update @samus, much appreciated. |
Summary
I'm working on migrating a code base to use 1.0 and encountering a strange crash while running unit tests. The schema being consumed has an enum that is nullable. In prior versions this was working fine. However now my tests crash with a sig abort when trying to access this one field. The code is failing in the
InputDict
struct inside the getter for the subscript operator. It is failing to cast a value of typeApolloAPI.GraphQLNullable<ApolloAPI.GraphQLEnum<MyGraphqlSchema.PetPolicyFilter>>
to what appears to be the same type.I'm only experiencing this crash while running unit tests. When I run the app in the simulator similar code works with no issue. It is also only happening inside an extension function
Version
1.0.6
Steps to reproduce the behavior
The extension method has some code to convert from the back end type to an app specific type.
This is using Xcode 14.2. I have tried switching the apollo dependency to use the main and release/1.1 branches but the problem is still the same.
Logs
Anything else?
No response
The text was updated successfully, but these errors were encountered: