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

feature: subscription HTTP callback support #1771

Open
dariuszkuc opened this issue Jan 8, 2024 · 6 comments
Open

feature: subscription HTTP callback support #1771

dariuszkuc opened this issue Jan 8, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@dariuszkuc
Copy link

Describe the Feature Request

GraphQL subscriptions enable clients to receive continual, real-time updates whenever new data becomes available. Unlike queries and mutations, subscriptions are long-lasting. This means a client can receive multiple updates from a single subscription.

WebSocket is the most commonly used subscription mechanism but it comes with few drawbacks - most notably it requires long lasting open connections. Apollo Router supports subscriptions using both the WebSocket and HTTP callback mechanism. HTTP callback protocol allows GraphQL servers to asynchronously send their subscription updates using regular HTTP POST requests which in turn allows you to scale you servers more easily.

HTTP callback protocol flow

  • initialization
    • router generates new unique subscription ID
    • routers sends subscription operation with additional extension data using regular HTTP POST request
    • subgraph responds with a check message
    • router responds with HTTP 204 (if successful)
    • subgraph responds with empty { "data": null } GraphQL response
  • main loop (run on some background thread)
    • subgraph sends heartbeats every X milliseconds (if enabled)
    • whenever new data is available, subgraph sends next message followed by complete message at the end of the stream

See also:

  • federation-jvm spring-graphl implementation of the protocol [link fix]

Describe Preferred Solution

DGS provides out of the box support for subscriptions using HTTP callback protocol.

Describe Alternatives

WebSocket based subscriptions are still viable option but don't scale as nicely.

@dariuszkuc dariuszkuc added the enhancement New feature or request label Jan 8, 2024
@srinivasankavitha
Copy link
Contributor

srinivasankavitha commented Jan 8, 2024 via email

@dariuszkuc
Copy link
Author

👍 Sounds good! Feel free to close the issue (or to keep it around until spring-graphql integration is completed).

@gwardwell
Copy link

It looks like DGS v8.3.0 updates to federation-jvm v4.4.0. Support for subscription callbacks was added in federation-jvm 4.2.0. Does this mean that DGS should support subscriptions via HTTP callback now? Or is it still blocked by the mentioned spring-graphql support since I see that work is being done in v8.2.6 RC releases?

@srinivasankavitha
Copy link
Contributor

Support for HTTP callbacks will be available in the spring-graphql integration in a future release, It is not available yet on existing releases.

@gwardwell
Copy link

Does the release of DGS 8.5.0 with Spring GraphQL integration mean subscription HTTP callbacks are now supported?

@paulbakker
Copy link
Collaborator

paulbakker commented Apr 8, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants