chore: use a service builder for axum layers#8928
Merged
goto-bus-stop merged 1 commit intodevfrom Mar 2, 2026
Merged
Conversation
A quick drive-by PR. I was trying to answer a question about CORS ordering and got a bit confused by this. By chaining `.layer`s directly onto an axum router, each next layer "wraps" the previous, so conceptually a request flows from the bottom to the top. tower has a `ServiceBuilder` where `.layer`s are applied in the opposite order, and this is kind of the common way to do things with tower. I think this is more intuitive because requests go through the layers in the order that you read them (and then responses go back up).
Contributor
✅ Docs preview readyThe preview is ready to be viewed. View the preview File Changes 0 new, 9 changed, 1 removedBuild ID: b36dd40861c90919f3982b68 URL: https://www.apollographql.com/docs/deploy-preview/b36dd40861c90919f3982b68 ✅ AI Style Review — No Changes DetectedNo MDX files were changed in this pull request. Review Log: View detailed log
|
This comment was marked as resolved.
This comment was marked as resolved.
carodewig
approved these changes
Feb 27, 2026
Contributor
carodewig
left a comment
There was a problem hiding this comment.
Definitely easier to reason about this way!
carodewig
pushed a commit
that referenced
this pull request
Mar 3, 2026
smyrick
pushed a commit
that referenced
this pull request
Mar 17, 2026
smyrick
pushed a commit
that referenced
this pull request
Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A quick drive-by PR. I was trying to answer a question about CORS ordering and got a bit confused by this.
By chaining
.layers directly onto an axum router, each next layer "wraps" the previous, so conceptually a request flows from the bottom to the top. tower has aServiceBuilderwhere.layers are applied in the opposite order, and this is kind of the common way to do things with tower. I think this is more intuitive because requests go through the layers in the order that you read them (and then responses go back up). axum also recommends doing it this way: https://docs.rs/axum/latest/axum/middleware/index.html#applying-multiple-middlewareIt's fundamentally not that important so feel free to close if deemed at all risky / not worth reviewer time. IMO, there is no risk to this change as long as reviewers agree that I've flipped the order exactly.
Checklist
Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.
Exceptions
It's a benign internal change.
Notes
Footnotes
It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this. ↩
Configuration is an important part of many changes. Where applicable please try to document configuration examples. ↩
A lot of (if not most) features benefit from built-in observability and
debug-level logs. Please read this guidance on metrics best-practices. ↩Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions. ↩