You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is currently not possible to incrementally stream chunks over the Http client as part of a multipart request.
This prevents using K6 to test APIs which use HTTP Multipart and streaming responses in incremental chunks, such as Apollo Router. Apollo Router uses HTTP Multipart with a --graphql boundary instead of websockets for GraphQL Subscriptions (Example accept header: multipart/mixed; boundary="graphql"; subscriptionSpec=1.0, application/json)
Suggested Solution (optional)
With k6/experimental/streams in experimental, it would be great if it could be used with the HTTP client.
In Node, using Fetch, it looks something like this:
fetch(actualUrl,{method: "POST",headers: {accept: 'multipart/mixed; boundary="graphql"; subscriptionSpec=1.0, application/json',"content-type": "application/json",},body: JSON.stringify(body),}).then((response)=>{constreader=response.body.getReader();// I can get a reader here!// Process each chunk as it comes inconstprocessChunk=({ done, value })=>{// ... code here ...// Read the next chunkreturnreader.read().then(processChunk);}returnreader.read().then(processChunk);});
As each chunk comes in, it is processed by the reader and then the fetch can be ended directly using an AbortSignal.
With K6, this isn't possible because it awaits the entire response and because it doesn't expose a getReader interface.
I'd love to be able to do something like this: (not married to this exact solution or function names)
This may not be the right solution. Open to whatever would be the "k6-way" to accomplish this as long as the end result is being able to stream a response incrementally from an API. :)
Already existing or connected issues / PRs (optional)
No response
The text was updated successfully, but these errors were encountered:
👋 Hello! ApolloGraphQL solutions architect here! :)
Feature Description
It is currently not possible to incrementally stream chunks over the Http client as part of a multipart request.
This prevents using K6 to test APIs which use HTTP Multipart and streaming responses in incremental chunks, such as Apollo Router. Apollo Router uses HTTP Multipart with a
--graphql
boundary instead of websockets for GraphQL Subscriptions (Example accept header:multipart/mixed; boundary="graphql"; subscriptionSpec=1.0, application/json
)Suggested Solution (optional)
With
k6/experimental/streams
in experimental, it would be great if it could be used with the HTTP client.In Node, using Fetch, it looks something like this:
As each chunk comes in, it is processed by the reader and then the fetch can be ended directly using an AbortSignal.
With K6, this isn't possible because it awaits the entire response and because it doesn't expose a
getReader
interface.I'd love to be able to do something like this: (not married to this exact solution or function names)
This may not be the right solution. Open to whatever would be the "k6-way" to accomplish this as long as the end result is being able to stream a response incrementally from an API. :)
Already existing or connected issues / PRs (optional)
No response
The text was updated successfully, but these errors were encountered: