SetErrorPresenter receives fresh r.Context(), not modified from server middleware
- Dominant language
- Go
- Stars
- 10.8k
- Forks
- 1.3k
- Avg merge
- 2d 36m
- Merged PRs (30d)
- 26
Description
### What happened?
The method `SetErrorPresenter` seems to be receiving a fresh context, a la the following code snippet:
```
if err := recover(); err != nil {
err := s.exec.PresentRecoveredError(r.Context(), err)
resp := &graphql.Response{Errors: []*gqlerror.Error{err}}
b, _ := json.Marshal(resp)
w.WriteHeader(http.StatusUnprocessableEntity)
w.Write(b)
}
```
https://github.com/99designs/gqlgen/blob/master/graphql/handler/server.go#L103-L108
However, we are mutating the context in our web middleware, and want to receive that mutated context. This is needed because we extract/inject data to align headers with context (i.e. present a unique request ID to the context, and other metadata).
### What did you expect?
The incoming context in `SetErrorPresenter` to contain the metadata from the middleware.
### Minimal graphql.schema and models to reproduce
Modify `ctx` in web middleware, compare to incoming `ctx` in `SetErrorPresenter`.
### versions
- `go run github.com/99designs/gqlgen version`? `v0.17.1`
- `go version`? `go version go1.18.1 darwin/amd64`
Contributor guide
Assessment
This issue has not been assessed yet.