Skip to content
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

Add additional hooks for boot up and schema events #6562

Open
smyrick opened this issue Jan 16, 2025 · 1 comment
Open

Add additional hooks for boot up and schema events #6562

smyrick opened this issue Jan 16, 2025 · 1 comment

Comments

@smyrick
Copy link
Member

smyrick commented Jan 16, 2025

Is your feature request related to a problem? Please describe.

Today for the Rust plugins, rhai scripts, and coprocessor you can hook into the follow request lifecycle stages

  • RouterService
  • SupergraphService
  • ExecutionService
  • SubgraphService (called for every subgraph)

All of these stages are called on the way down processing the REQUEST as well as on the way back up processing the RESPONSE

To get access to other artifacts or change the Router behavior I have to use these lifecycle which all are hit for every single request so if I want information below I must serialize and send it as bytes on every request and keep track of the state myself too

  • The supergraph version and SDL
  • The current router config settings
  • The operations and data in the cache

Describe the solution you'd like

It would be alot easier to keep track of the Router state if in the internal Router state machine we also called out to the customizations when there was an event

  • RouterBootup
  • SupergraphLoad / Reload
  • RouterShutdown
  • PersistedQueryManifestLoad
  • CacheAddition/Invalidation

This would allow us to power more advanced usecases not only for the internal Router code base and our own product but also give customers and solutions teams access to build unique features that might not be for everyone.

  • Save the supergraph SDL in Coprocessor to do custom validation and update on reload
  • Pre-warm the query plan caches with my own custom list of operations
  • Change the boot up configuration settings with data loaded from dynamic services
  • Add custom logic if data should be cached or not

Describe alternatives you've considered

Even in Rust code itself, there is no external call during these events so we are forced to do all external processing on every request.

@smyrick
Copy link
Member Author

smyrick commented Jan 16, 2025

Also related is the behavior if a coprocessor fails: #3271

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant