Accept event-stream for POST for urql-graphql #3276
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #3275
There was an attempt to support SSE, but it broke HTTP POST.
#3153 added the following to the HTTP POST transport:
gqlgen/graphql/handler/transport/http_post.go
Lines 30 to 32 in 4157ef9
From a general HTTP point of view though, the
Accept
header is there to communicate which content types the client can understand, and indeed clients like javascript'surql
advertise that they can understand SSE, even when the server is only set up to support POST. The presence oftext/event-stream
in the client's accept header shouldn't mean that the request can't be served by HTTP POST.For instance, the javascript client
urql
, has this header hardcoded for every request:https://github.com/urql-graphql/urql/blob/b9f34fd19ee5f9022db4d2f9eb610943c787dac1/packages/core/src/internal/fetchOptions.ts#L149-L154
Signed-off-by: Steve Coffman steve@khanacademy.org