-
Notifications
You must be signed in to change notification settings - Fork 298
Move operation limits enforcement into a layer #7611
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: dev
Are you sure you want to change the base?
Conversation
✅ Docs preview has no changesThe preview was not built because there were no changes. Build ID: 98e453b33aa2d2d7240a296c |
apollo-router/src/plugins/limits/enforce_operation_limits_layer.rs
Outdated
Show resolved
Hide resolved
type Service = EnforceOperationLimits<S>; | ||
|
||
fn layer(&self, inner: S) -> Self::Service { | ||
EnforceOperationLimits { |
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.
We could also use one of the .map_future
-style layers here to implement the service. I think it's a pretty good exercise to get into writing our own services though, once you understand them it's not that hard... and we all need to understand them to work with tower effectively.
edfc3f9
to
ead890c
Compare
@goto-bus-stop, please consider creating a changeset entry in |
ead890c
to
fbdda50
Compare
✅ Docs preview readyThe preview is ready to be viewed. View the preview File Changes 0 new, 3 changed, 0 removed
Build ID: 0206cb525df1b27561168acd URL: https://www.apollographql.com/docs/deploy-preview/0206cb525df1b27561168acd |
An example of the refactoring unlocked by #7610.
Operation limits enforcement can be done in a layer at the supergraph service. This way it's a composable piece of functionality that we can add or remove in a single-line code change. This also means it's done a bit earlier in the pipeline. And that we don't need to thread the generated query metrics through the query planner service just to be able to put it in context. Because we don't need a bunch of hardcoded bits in the query planner service to do this, we can actually move all operation limits code into the limits plugin.