Closed michaelloo closed 3 months ago
I believe this is a known issue @michaelloo, and unfortunately we don't have a workaround that isn't manual at the moment. Xcode really should just be able to handle this to be honest. A solution that works with codegen may have to be adding a name suffix to each file with what kind it is; AddressInputObject
, AddressObject
, etc.
😢 Ah ok... we'll have a script them to rename the file for now after updating the models, thanks for the response!
Hi @calvincestari , on a somewhat related note, what is the suggested approach if we have the same codebase relying on multiple APIs with different GraphQL schemas? Meaning having multiple apollo-codegen-config.json
files but the generate code might have filename conflict, e.g.:
error: Filename "SchemaConfiguration.swift" used twice: 'some/path/GeneratedFiles/Schema/SchemaConfiguration.swift' and 'some/other/path/GeneratedFiles/Schema/SchemaConfiguration.swift' (in target 'XXX' from project 'XXX')
Apollo iOS is not designed to work with multiple schemas at once and to do so requires a bit of careful configuration.
To resolve the duplicate SchemaConfiguration.swift
you'll need to generate the schemas into different targets/packages, I believe that should resolve the issue.
I see, we'll get onto that but this isn't an ideal solution so i've opened a separate feature request here 🙏
A workaround for this is being implemented currently. See #3283 for more info. Once that is released, you'll be able to change the generated names of these types (including file names) to AddressInputObject
and AddressType
(or any names you choose).
The workaround for this in #3283 has been shipped in 1.13.0
. That is now the suggested solution when dealing with this problem in the future. Closing this issue.
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better.
Summary
If you have an
INPUT_OBJECT
type with nameAddress
, and aOBJECT
type with the same nameAddress
, you end up with a conflictingfilename
which causes an Xcode compile issue:The struct name are ok because they are nested under different levels:
Version
1.9.0
Steps to reproduce the behavior
apollo-codegen-config:
I am unable to give you a full view of the schema unfortunately but here are some snippets of it:
If I rename one of the conflicting files, then I am able to get through this error, (e.g.:
AddressInput
).Logs
No response
Anything else?
Is there a way to specify the output to be in a single file (like it used to be able to do)? Then I can avoid this filename conflict