-
Notifications
You must be signed in to change notification settings - Fork 345
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
Runtime Package Redesign #861
Comments
Thank you for bringing those awesome ideas! As I see, you have a problem of extending GraphQL Mesh with custom plugins because of the strict validation of configuration package. So we can make it more flexible instead of doing a big refactor. We can allow people to use their custom merger, handler or transform by making that config validation more flexible in case of the usage of an unknown extra package/module/plugin name. For dynamic schema manipulation, we were already thinking of using hooks which is based on EventEmitter. Typed events like I am not sure about making all concerns under a single plugin approach because handling sources, transforming schemas, stitching them and stuff are different concerns. We should keep all these seperated in my opinion. @dotansimha What do you think? |
Awesome! I wasn't aware of the new config package, so it looks like that issue with runtime being coupled is resolved. However, the underlying problem is still there, since the config package validation depends on the We can write our own If we can just pass in the raw yaml config, then we could also abstract away the concern of loading the yaml config. The runtime package would have a default way to load it, of course, but we can load it ourselves if we need to through any means and just pass it directly to Regarding plugins, there would be different plugin types, like mergers and handlers, but allowing them all to implement a single interface would make certain plugins reusable in different contexts (for example, the federation plugin could be a handler, transform, and merger. It would know which action to perform based on a parameter passed in by the runtime). This would allow us to combine handlers/transforms/mergers that are closely related together into one package. Of course, if you only want to implement a transform or a handler, you could write a plugin just for that type. |
#907 |
This is great! Thanks for your work on this! Two other suggestions I was thinking:
merger: stitching
sources:
- name: "outerSource"
merger: federation
sources:
- name: ... This would basically allow us to recursively nest the mesh config structure within a source, so that the source config would look something like: export type MeshResolvedSource<TContext = any> = {
name: string;
handler: MeshHandler<TContext>;
transforms?: MeshTransform[];
}
| GetMeshOptions;
Of course, we have the option of writing our own transform to do this, but that would make the current These are both use cases I've encountered so far, and having these capabilities would be helpful. I can also help with implementing one or both of them if you agree. Curious to hear your thoughts! |
Sorry I accidentially closed the issue :) |
…#861) Co-authored-by: Renovate Bot <[email protected]>
Hey guys! First I just want to say I love this project and the ease that it gives us in composing graphql schemas declaratively. Thank you for all of your hard work!
To improve this library even more, I have a couple suggestions for the design of the
runtime
package to solve a couple issues. Right now, the runtime package is highly coupled to the handler, merger, and transform libraries because it uses types from each library and validates against them. Furthermore, there's no easy way I see to add our own custom handlers/mergers/transforms without adding them to thegraphql-mesh
monorepo.These problems can be solved if we treat the runtime package as a core framework library and use dependency injection instead. We can think of handlers, mergers, and transforms as
plugins
that we use in our yaml file. The runtime package that loads our yaml file has no knowledge of what these actual plugins are, it just knows that they follow a certain contract. An example for this contract could be something like the following:where each plugin is given the current schema and returns the transformed schema. The
graphql-mesh
framework can additionally pass in other configs to the options object that are user-specified in the yaml file, making these plugins declarative and behave similarly to how the standard plugins behave now.This gives us several advantages:
PluginLoader
provider that's responsible for returning plugins by name to the core runtime package. This would allow us to dynamically load configs as requested in Feature request: dynamic adding of the service to Mesh #642To illustrate this design, I made a proof of concept MVP, and I've been using it to much success on my own projects. Please reference the wiki and the
core
package specifically. If you agree with this design, I'm entirely willing to donate this package tographql-mesh
, or help with creating a new one. Just let me know your thoughts.This is a great library and I'm very excited to help with its development. Thank you once again for this awesome project!
The text was updated successfully, but these errors were encountered: