consider removing/disallowing schema cycles #1143
Replies: 2 comments
-
hmmm 🤔 I see two different issues here: First: We could break these circular dependencies at the definition layer, but that seems a bit awkward - we'd be splitting up defs like Second & probably harder to resolve: One possible middleground solution would be to group all defs (not records/queries/procedures/subscriptions) in a single file & then have separate code-genned files for each of the higher order lexicons Thoughts? |
Beta Was this translation helpful? Give feedback.
-
One possibility in this specific case might be to fold all the definitions from
This is potentially not hard to resolve AFAICS, by moving Here's a patch that demonstrates both possibilities (but it does move the In general, my experience with Go packages tells me that although avoiding cycles is a pain at times, the resulting acyclic dependency patterns are almost always better engineered and easier to understand, so it might well be worth sorting out/clarifying this issue while it's easy to do.
This doesn't seem like it would scale very well to me when there are an arbitrary number of namespaces around, because we might want to generate code for different namespaces in different, separately generated, modules, which precludes having a single unified view of all definitions in one place. |
Beta Was this translation helpful? Give feedback.
-
Currently a small number of the lexicons introduce cycles, a.k.a. circular dependencies.
This makes it awkward to generate code in languages such as Go which don't allow cyclic package dependencies.
One way to do it is to merge all lexicons into a single package, but that's not ideal:
keeping an isomorphism between lexicons and the generated code seems like a nice property.
Here's an itemized list of all the circular dependencies currently (as of commit e9ba4a7).
Each cycle is shown as a separate section. The indented parts show the actual definition-level dependencies.
It's possible to break the cycles with a three line change, although clearly that would break compatibility.
Beta Was this translation helpful? Give feedback.
All reactions