apollo-ios: Invalid Redeclaration of a Model
our server has a model with two fields:
discount: Discount
deliveryDiscount: Discount
when I downloaded the schema there were two struct for Discount
and I got this error :
/Users/hamed/Documents/workspaces/ice/Modules/Core/Network/Sources/Network/Schemas/Operations/cart.graphql.swift:5682:25: Invalid redeclaration of 'Discount'
when I remove one of them from my .graphql
file everything is OK
I asked our other developers (android and front) they don’t have this issue could you please answer me?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (8 by maintainers)
@calvincestari I will take a look at the linked issue. Thank you for the quick response!
I’m experiencing an issue similar to this using
1.0.6
.In my case the schema contains something like:
which is causing the
Type
struct to be generated twice leading to theInvalid redeclaration of 'Type'
errorThis is definitely odd behavior. I’m almost certain this won’t exist in the 1.0 version, as we’ve re-written the entire code generation engine. While it is a breaking change, we hope the migration to 1.0 isn’t terribly difficult or painful. In most cases, it shouldn’t cause you to have to make massive re-writes, just setting up the new codegen and changing some call sites perhaps.
As for the old codegen, it might be more helpful if we could take a look at your schema as well. I understand that is probably sensitive data, so if you can’t share it with us I understand. Or if you could share it with us privately rather than via a public link, I’d love to take a look at that.
I’ll be honest, the reason we re-wrote the codegen engine for 1.0 is that the old codegen engine was buggy and very difficult to make changes to. If there is something wrong in your schema or operations that we can deduce to help resolve this great, but its unlikely that we are going to be able to allocate the resources to digging into the legacy code generation engine and fixing bugs there.
The 1.0 is very close to being stable now, and I highly recommend you being the process of migrating to this version when you are able to. Specifically because we don’t intend to maintain the legacy codegen engine any longer. The 1.0 Beta 2 is going to be released soon (hopefully today!) and we expect that to be very very close to ready for a General Release.
@calvincestari cart.graphql.swift.zip
Can you share some of the generated code - the structs where the duplication is happening?
We don’t have any bug reports of this kind of problem with the current 0.53.0 version. I’m surprised why two fields of the same type would duplicate the
Discount
struct so I’m trying to narrow down whether this is the result of a recent change.1.0 is a breaking change, there are many changes and improvements to the API.