-
Notifications
You must be signed in to change notification settings - Fork 730
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
Make Codegen Namespacing Optional #3164
Comments
Hi @Mordil, this is already available with the |
@calvincestari Then documentation needs to be updated as this is not clearly explained and actually seems counter-intuitive from the symbol docs on the enum options. The and |
Yes I can see how mention of CocoaPods specifically confuses the issue. I can clean that up.
I'll include details on this for |
What about for the use case where I want all of my schema types to be defined in one module, but all of my operations are defined in downstream modules, but I don't want to namespace the schema types in the sole module? What configuration combination should I use?
|
For context in this other use case, we want a top level schema module that has all of the "currency" types of the schema, as public, and then we want each submodule to encapsulate the operations as internal, only exposing the currency types to our app that imports these operation modules. What way can we setup the configuration to have the submodules import the schema module, and control over their access modifiers? |
I think you should still be able to use a schema module type of
I think the above configuration should satisfy that.
|
Thank you, this helps immensely simplify the upgrade path we were facing |
Glad to help. The configuration is quite flexible but difficult to fully explain it's capabilities in documentation without concrete examples that could never cover every possible configuration. |
In the Archive.zip example, where does the |
It's the name of the project the files get added to, or the name of the SPM package, or the name of the pod. |
I've noticed with this configuration there's a bug that stops it from compiling - when generating the schema types for the submodules it's adding the namespace to the |
If I am trying to integrate Apollo into a project that uses its own build system that doesn't necessarily fit into those 3 things, trying to specify this namespace doesn't work. It will produce an error |
Never mind on this... after spending more time debugging, I had realized this schema module still contained the autogenerated struct that re-uses the module's name. |
@guillianbalisi we try to be flexible as possible but there will be bounds to what we have built so far. Can you share a few more details about the custom build system and what it creates in terms of modules, etc.? |
Using Bazel with bazel-ios rules (apple_framework) to define modules, and building modules using |
Use case
The Codegen API tries to support many architecture use cases, and in some it's possible to have name collisions if the generated code happens to be in the same module.
This is resolved by wrapping the code in a namespace enum, which is configurable.
However, this is completely unnecessary in some architectures, where all the generated code is encapsulated in a single Swift module - the Swift module acts as the namespace.
This is particularly painful for projects that are upgrading from the previous codegen to the new, where thousands of lines of code are needing to be updated to append the namespace, with no other changes to the type reference.
Describe the solution you'd like
In the Codegen API,
namespace
should be entirely optional.The text was updated successfully, but these errors were encountered: