-
Notifications
You must be signed in to change notification settings - Fork 468
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
Compilation errors when generating a mutation with NonNullable Input #185
Comments
@martijnwalraven is apollo android uses same code gen? we see the issue there as well. |
@pranayairan: Apollo Android uses |
@martijnwalraven There are at 3 possible solutions I found for reference cycles with value types: Solution 1: Change at least one of the structs to class, to make a reference cycle, you need at least one reference. Solution 2: As mentioned here: indirect enums and structs, an elegant solution could be to wrap your reference inside an enum with an indirect case. For example,
Indirect tells the compiler there is a recursion in your enum, and it should insert the necessary layer of indirection. Solution 3: Create a wrapper type backed by a class instance to provide the necessary indirection:
You can now just use the Indirect wrapper for one (or both) of your structs properties:
|
This should be fixed in apollo-codegen 0.16.2. @weapon3042: Thanks for looking into solutions for avoiding reference cycles with value types. In this case, the easiest solution seemed to be to replace stored properties with computed properties, because the end result should be a |
@martijnwalraven Thanks! |
When doing the following mutation in Swift, the generated classes do not compile
Schema:
Mutation
Errors:
The text was updated successfully, but these errors were encountered: