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

Pre-Supergraph Router service layer (HTTP) #1496

Closed
SimonSapin opened this issue Aug 11, 2022 · 8 comments · Fixed by #2170
Closed

Pre-Supergraph Router service layer (HTTP) #1496

SimonSapin opened this issue Aug 11, 2022 · 8 comments · Fixed by #2170
Assignees

Comments

@SimonSapin
Copy link
Contributor

Currently we provide:

  • A full server that listens for a network requests of various kinds, typically for production use
  • A Tower Service for handling GraphQL requests with high-level request and response objects, typically for use in tests

It would make sense to provide the intermediate abstraction of Tower service at the HTTP level, where request and response bodies are raw bytes. This could potentially be run in a different HTTP server.

For 1.0 we want to at least have the separation internally, though perhaps not yet provide a public API for it.

@SimonSapin SimonSapin self-assigned this Aug 11, 2022
@SimonSapin SimonSapin changed the title HTTP service abstraction Transport- / HTTP-level abstraction Aug 22, 2022
SimonSapin added a commit that referenced this issue Aug 22, 2022
SimonSapin added a commit that referenced this issue Aug 22, 2022
SimonSapin added a commit that referenced this issue Aug 22, 2022
SimonSapin added a commit that referenced this issue Aug 23, 2022
@SimonSapin
Copy link
Contributor Author

Removing the api/1.0 label now that #1582 ensures that the abstraction can exist. Leaving this issue open so we can decide later if we want a public API to construct this transport-level Service. (Likely with a builder similar to TestHarness.)

SimonSapin added a commit that referenced this issue Aug 23, 2022
@SimonSapin SimonSapin removed their assignment Aug 23, 2022
SimonSapin added a commit that referenced this issue Aug 25, 2022
@abernix
Copy link
Member

abernix commented Oct 24, 2022

As some examples of user-land things which we could enable by supporting this, both of the following use-cases come to mind — though I have closed those issues as "working as intended" in for the common Router user story:

  • axum refuses the text/plain content type #1298
    This requests a way to accept different content types, like text/plain. I'm not entirely sure what a text/plain GraphQL query would be (and it would go against work that the GraphQL HTTP working group is trying to specify about how GraphQL should speak HTTP) but it would be good to enable users to make such exceptions if need be, most likely to preserve existing behaviors where necessary.
  • can't parse variables from a string #1314
    This suggests allowing a different serialization format for incoming variables and a transport-level service might enable them to coerce that data into a valid GraphQL variables structure.

@lennyburdette
Copy link
Contributor

The most pressing customer use case I have is supporting a custom persisted query implementation. They have old mobile clients sending a weird PQ format and it will take a long time for those version to die off. They handled this in express middleware when using Apollo Gateway.

@abernix abernix changed the title Transport- / HTTP-level abstraction Pre-Supergraph HTTP service layer Nov 18, 2022
@SimonSapin
Copy link
Contributor Author

SimonSapin commented Nov 18, 2022

This is relevant:

// For now this is unused:
#[allow(unused)]
// Later we might add a public API for this (probably a builder similar to `test_harness.rs`),
// see https://github.com/apollographql/router/issues/1496.
// In the meantime keeping this function helps make sure it still compiles.
async fn make_transport_service<RF>(
schema: &str,
configuration: Arc<Configuration>,
extra_plugins: Vec<(String, Box<dyn DynPlugin>)>,
) -> Result<transport::BoxCloneService, BoxError> {

An open question that remains is how (and whether?) to expose multiple TCP/Unix listeners

@Geal
Copy link
Contributor

Geal commented Nov 18, 2022

An open question that remains is how (and whether?) to expose multiple TCP/Unix listeners
that would not affect HTTP service plugins, right?

@SimonSapin
Copy link
Contributor Author

If something like the Prometheus endpoint is configured on a secondary TCP port, should HTTP-level plugins run for those requests as well? Should they be responsible for always checking some property of the request to dispatch on port number as well as URL path?

@o0Ignition0o
Copy link
Contributor

Do yall have opinions on where the http_service should kick in (as in before or after axum routing?)

My opinion is that it should be right after axum routing (The http service stack should only apply to the graphql path) and before anything else happens (headers parsing || studio redirection or body deserialization shouldn't have happened before)

I've also read mentions of the http_service applying before the axum router, I would be interested to read thoughts on that, especially since we now have custom endpoints that could satisfy that.

@bnjjj
Copy link
Contributor

bnjjj commented Nov 24, 2022

I think having it just after the axum routing makes sense. It should take a raw http request (without json deserialization) and return a raw http response I think

@o0Ignition0o o0Ignition0o changed the title Pre-Supergraph HTTP service layer Pre-Supergraph Router service layer (HTTP) Nov 29, 2022
o0Ignition0o added a commit that referenced this issue Dec 16, 2022
Fixes #1496

A `router_service` is now part of our service stack, which allows plugin developers to process raw http requests and raw http responses, that wrap the already available `supergraph_service`
@abernix abernix added this to the v1.7.0 milestone Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants