prisma-labs / graphql-framework-experiment

Code-First Type-Safe GraphQL Framework
https://nexusjs.org
MIT License
673 stars 66 forks source link

addToContext should only see request headers #509

Open jasonkuhrt opened 4 years ago

jasonkuhrt commented 4 years ago

Perceived Problem

The API is bloated, currently exposing HTTP.IncomingMessage, so an event emitter, so on:

image

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)

Related

jasonkuhrt commented 4 years ago

Would be made obsolete by https://github.com/graphql-nexus/nexus-future/issues/524