The API is bloated, currently exposing HTTP.IncomingMessage, so an event emitter, so on:
It is not appropriate. It is not how we would design it from scratch. It is inherited without having been really reflected upon.
Aside from burdening the autocomplete DX for users, it permits nonsense:
schema.addToContext(req => {
req.destroy() // possible but senseless
})
Ideas / Proposed Solution(s)
A new constrained type, about just data
just http headers
either schema.addToContext(({ headers }) => )
or schema.addToContext((headers) => )
Call the type... RequestData or NexusRequestData
Do we need plugins to be able to contribute typegen here?
What if there is server middleware that does some complex logic and wants to add some derived values to the request object which then the user wants to add to context?
answer seems to be... don't... cut the indirection and bring schema.addToContext to where you need it...
Perceived Problem
The API is bloated, currently exposing HTTP.IncomingMessage, so an event emitter, so on:
It is not appropriate. It is not how we would design it from scratch. It is inherited without having been really reflected upon.
Aside from burdening the autocomplete DX for users, it permits nonsense:
Ideas / Proposed Solution(s)
schema.addToContext(({ headers }) => )
schema.addToContext((headers) => )
RequestData
orNexusRequestData
schema.addToContext
to where you need it...Related
506