Join us from October 8-10 in New York City to learn the latest tips, trends, and news about GraphQL federation and API platform engineering.Join us for GraphQL Summit 2024 in NYC
Docs
Start for Free

Enabling HTTP Subscriptions with the Apollo Router and an API Gateway

Enable HTTP multipart subscriptions when using an API gateway in front of the router

router

Learn how to configure an API gateway to support HTTP multipart with the .

Organizations can require their APIs—including the Apollo Router—to be fronted by an API gateway. API gateways often aren't configured to support subscriptions over HTTP multipart: API gateways by default usually buffer HTTP responses, but subscriptions over HTTP multipart require multipart responses to be streamed, not buffered.

The rest of this article describes how to configure API gateways from different vendors to stream and not buffer HTTP responses, therefore supporting subscriptions over HTTP multipart.

Azure API Management (APIM)

By default, an HTTP API endpoint in APIM buffers each response from a downstream service, where the endpoint must receive all chunks of an HTTP response before it sends the response to the client.

To enable HTTP subscriptions, the forward-request policy on the backend must be updated with buffer-response="false". This configures the HTTP API endpoint to send the chunks of a response to the requesting client as they are received.

<policies>
<backend>
<forward-request http-version="2or1" buffer-response="false" />
</backend>
</policies>

Google Apigee

By default, an HTTP API endpoint in Apigee buffers each response from a downstream service, where the endpoint must receive all chunks of an HTTP response before it sends the response to the client.

To enable HTTP subscriptions, the response.streaming.enabled property must be set to true in both your ProxyEndpoint and TargetEndpoint definitions in the proxy bundle. This configures the HTTP API endpoint to send the chunks of a response to the requesting client as they are received.

<TargetEndpoint name="default">
<HTTPTargetConnection>
<URL>http://mocktarget.apigee.net</URL>
<Properties>
<Property name="response.streaming.enabled">true</Property>
</Properties>
</HTTPTargetConnection>
</TargetEndpoint>
<ProxyEndpoint name="default">
<HTTPProxyConnection>
<BasePath>/v1/weather</BasePath>
<Properties>
<Property name="response.streaming.enabled">true</Property>
</Properties>
</HTTPProxyConnection>
</ProxyEndpoint>

Mulesoft

Flex Gateway

Streaming of HTTP multipart is supported out of the box with no additional configuration required.

Proxy (Mule 4, CloudHub 2.0)

Streaming of HTTP multipart isn't supported. Use Flex Gateway instead.

Kong

Streaming of HTTP multipart is supported out of the box with no additional configuration required.

AWS API Gateway

AWS API Gateway doesn't support streaming of HTTP data.

A possible workaround is to use a Lambda expression which does support streaming. To learn more, see AWS Lambda response streaming.

Next
Home
Rate articleRateEdit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy

Company