graphql-platform icon indicating copy to clipboard operation
graphql-platform copied to clipboard

Allow to add response headers in IHttpResultSerializer

Open snifter opened this issue 3 years ago • 0 comments

Is your feature request related to a problem?

In some cases i want to set custom http status and add header to response. IHttpResultSerializer allow to modify response status but unable to add header. At this time a workaround is to inject HttpContextAccessor to IHttpResultSerializer implementation and add header on HttpContext.Response. IMO it is a code smell because method GetStatusCode has side effect.

The solution you'd like

Add a method IReadOnlyDictionary<string, StringValues> GetResponseHeaders(IExecutionResult result) to IHttpResultSerializer and add its result to HttpContext.Response.Headers. Another solution would be to allow to access HttpContext.Response in IHttpResultSerializer.

Product

Hot Chocolate

snifter avatar Aug 02 '22 05:08 snifter