Open giulio-opal opened 1 day ago
I'm experiencing the same issue as mentioned (but using echo instead of gin). An interesting observation is that if I send the query through an apollo router, it works. I know it's not a solution to the problem posted, just thought it would be worth mentioning.
What happened?
I'm using Apollo GraphQL on the frontend, which automatically passes
accept: multipart/mixed
as header when the query contains a@defer
directive. Unfortunately this causes the gqlgen server to expire the context and actually not return the deferred fields.If I were to use
accept: text/event-stream
as header, the gqlgen server actually handles the context correctly and returns the deferred data.Example:
What did you expect?
Context to not expire and subsequent multipart responses returned to the frontend.
Is there an additional configuration that needs to be set up in the gqlgen server or in Gin that I might be missing?
Minimal graphql.schema and models to reproduce
Example repo based off the official documentation with gin: https://github.com/giulio-opal/defer-gqlgen-todo-example
It also contains a custom playground (GraphiQL) based off https://github.com/99designs/gqlgen/issues/2771#issuecomment-1694692940
versions
go run github.com/99designs/gqlgen version
? v0.17.49+go version
? 1.22.0