-
Notifications
You must be signed in to change notification settings - Fork 734
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
CodegenCLI - File name collision if Fragment has the same name as Type #2598
Comments
Thanks for the bug report @p4checo. I'd prefer not to add yet another configuration option, there are already too many. I'd rather opt for a consistent "Fragment" suffix on the filename. I'll see if there are any other options. |
Hey, |
@SzymonMatysik, no fix available yet. The work is slated for the |
I am also having this issue after migrating to the new codegen cli now that we switched from cocoapods to SPM. Is there any work around so we don't have to rename 50+ files after generating them? |
Hi @jostster - the only options currently are:
|
Yea for now I created a bash script to generate then rename all the files. Is there a flag or option to have all the generated files be combined into a single file? Since they are generated and shouldn't be edited this could also ease the burden and help larger projects not have a bunch of different generated files. |
No, the legacy (0.x) versions used to have that option but it was removed in 1.0 to support modular architectures. It was also a poor performance option re. Xcode when it was an unwieldily large file. |
This will be fixed by #3283. |
Any update here? |
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. |
@calvincestari custom naming doesn't solve this issue. When fragments are named the same thing as the type, the file names conflict. Resolving this via custom naming means manually adding an entry for each fragment, which at that point might as well just change the name of the fragment in the .graphql file. So it's not really a solution. I suggest this issue is reopened, unless you want to explicitly forbid fragments to have the same name as the type, which seems silly for the client to make such an opinionated rule. |
Renaming the type should result in a different file name. If that's not happening it's probably a bug and worthy of creating an issue. Ideally Xcode would understand they're at a different path and this problem wouldn't exist. |
@calvincestari sorry if I was unclear. Forcing users to rename is not a solution to this issue. |
We didn't implement this because it wasn't going to be a good experience for people who aren't running into this problem. If you have a "Forcing users to rename their fragments" only happens during the initial migration to 1.0. If you were creating a new project from scratch, you would encounter this issue once and just name your fragments differently going forward. This is one of the many pain points with the 1.0 migration. But we didn't want to add a "feature" that actually isn't desired behavior usually forever to slight ease the migration path here. |
There's no need to rename the fragment, just the filename. The original proposal here was to name fragment files |
Bug report
In our setup we define fragments with the same name as the schema types, e.g.:
While this wasn't an issue with the previous single-file codegen, in the current multi-file codegen of Apollo 1.0.x this is causing an issue because two files with the same
ProductImage.graphql.swift
name are generated (one in/Schema/Objects
and another in/Fragments
). This causes compilation fail with an error like this:The generated types themselves are properly namespaced so they don't collide, it's only the filenames themselves cause the problem:
Fragment
Object
While we can rename all our fragments to not have the same name as the type, we feel that this could also be fixed at the codegen phase, by adding a Fragment suffix to the file (e.g.
Foo.Fragment.graphql.swift
) instead of relying only on the folder structure (which can possibly cause other similar collisions). Would it make sense? Could also be added as a parameter of the config.Versions
Please fill in the versions you're currently using:
apollo-ios
SDK version: 1.0.1Steps to reproduce
The text was updated successfully, but these errors were encountered: