Come up with code pattern for integrating two enterprise features
Created by: eseliger
Currently, it is hard to combine logic from two enterprise features.
At Batch Changes, we've been prototyping a Batch Changes <-> Code Monitoring integration during the hackathon week and a major problem was using the two enterprise packages for each other, especially on the GraphQL layer but also more generally.
For GraphQL, we added a 3rd schema file called batchescodemonitors.graphql
that describes the overlap of those two feature areas. But then, the interfaces of the resolvers need to 100% match whats in the schema - so we would need to implement the resolvers in the batches/resolvers
package and in the codemonitors/resolvers
package respectively. That causes cyclic imports quickly though.
So we want to find a general pattern to use two enterprise packages together, without compiler errors.
After some experimentation, a third package to hold some variables that get assigned to on init was the only feasible thing we found so far, but it isn't great as it's hard to read, debug and test.
package A
func init() { AB.GetA = getA }
func doSomethingWithB() { AB.GetB().Do() }
package B
func init() { AB.GetB = getB }
package AB
var GetA, GetB
Input greatly appreciated!