Skip to content

chore: use a service builder for axum layers#8928

Merged
goto-bus-stop merged 1 commit intodevfrom
renee/driveby-layer-order
Mar 2, 2026
Merged

chore: use a service builder for axum layers#8928
goto-bus-stop merged 1 commit intodevfrom
renee/driveby-layer-order

Conversation

@goto-bus-stop
Copy link
Copy Markdown
Member

@goto-bus-stop goto-bus-stop commented Feb 27, 2026

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 a ServiceBuilder where .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-middleware

It'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.

  • PR description explains the motivation for the change and relevant context for reviewing
  • PR description links appropriate GitHub/Jira tickets (creating when necessary)
  • Changeset is included for user-facing changes
  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Metrics and logs are added3 and documented
  • Tests added and passing4
    • Unit tests
    • Integration tests
    • Manual tests, as necessary

Exceptions

It's a benign internal change.

Notes

Footnotes

  1. 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.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. A lot of (if not most) features benefit from built-in observability and debug-level logs. Please read this guidance on metrics best-practices.

  4. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

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).
@goto-bus-stop goto-bus-stop requested a review from a team as a code owner February 27, 2026 10:23
@apollo-librarian
Copy link
Copy Markdown
Contributor

apollo-librarian bot commented Feb 27, 2026

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

0 new, 9 changed, 1 removed
* graphos/routing/(latest)/configuration/yaml.mdx
* graphos/routing/(latest)/customization/coprocessor/index.mdx
* graphos/routing/(latest)/customization/coprocessor/reference.mdx
* graphos/routing/(latest)/observability/router-telemetry-otel/enabling-telemetry/selectors.mdx
* graphos/routing/(latest)/observability/router-telemetry-otel/enabling-telemetry/spans.mdx
* graphos/routing/(latest)/observability/router-telemetry-otel/enabling-telemetry/standard-instruments.mdx
* graphos/routing/(latest)/security/demand-control.mdx
* graphos/routing/(latest)/security/router-authentication.mdx
* graphos/routing/(latest)/_sidebar.yaml
- graphos/routing/(latest)/performance/circuit-breaking.mdx

Build ID: b36dd40861c90919f3982b68
Build Logs: View logs

URL: https://www.apollographql.com/docs/deploy-preview/b36dd40861c90919f3982b68


✅ AI Style Review — No Changes Detected

No MDX files were changed in this pull request.

Review Log: View detailed log

This review is AI-generated. Please use common sense when accepting these suggestions, as they may not always be accurate or appropriate for your specific context.

@github-actions

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@carodewig carodewig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely easier to reason about this way!

@goto-bus-stop goto-bus-stop merged commit 15d3e4a into dev Mar 2, 2026
15 checks passed
@goto-bus-stop goto-bus-stop deleted the renee/driveby-layer-order branch March 2, 2026 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants