-
Notifications
You must be signed in to change notification settings - Fork 0
feat(core): define module registry and lifecycle hooks #27
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
base: topic/kaialang-eng-1063-open-core-module-system-v1
Are you sure you want to change the base?
feat(core): define module registry and lifecycle hooks #27
Conversation
Router image scan failed❌ Security vulnerabilities found in image:
Please check the security vulnerabilities found in the PR. If you believe this is a false positive, please add the vulnerability to the |
func (c *coreModules) initMyModules(ctx context.Context, modules []MyModuleInfo) error { | ||
hookRegistry := newHookRegistry() | ||
|
||
for _, info := range modules { | ||
moduleInstance := info.New() | ||
|
||
hookRegistry.AddApplicationLifecycle(moduleInstance) | ||
hookRegistry.AddGraphQLServerLifecycle(moduleInstance) | ||
hookRegistry.AddRouterLifecycle(moduleInstance) | ||
hookRegistry.AddSubgraphLifecycle(moduleInstance) | ||
hookRegistry.AddOperationLifecycle(moduleInstance) | ||
} | ||
|
||
c.hookRegistry = hookRegistry | ||
|
||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that all of my modules will be registered to all lifecycles? doesn't this mean that these modules will run on all hooks and there is no flexibility if I want to register my module on specific hook? Maybe MyModuleInfo should have a field that represents a list of hooks that you want this module to be registered and run on.
Let me know if I am not understanding things correctly.
for _, m := range r.modules { | ||
modules = append(modules, m) | ||
} | ||
return sortMyModules(modules) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess is that this will be called from each hook to get the list of modules to run?
I wonder if we can have a data structure that keeps lifecycle/hook to modules mapping (or update moduleRegistry
to have that mapping), and sort the module order on register time so that we don't have to sort on hook runtime.
Motivation and Context
This PR implements wundergraph#1063. The PR includes:
Checklist