VulcanJS / Vulcan

🌋 A toolkit to quickly build apps with React, GraphQL & Meteor
http://vulcanjs.org
MIT License
7.98k stars 1.88k forks source link

add graphql.context callback #2689

Closed Apollinaire closed 3 years ago

Apollinaire commented 3 years ago

Simply add a server-side callback called graphql.context that lets us iterate and modify the context passed to resolvers. It will run once per request, at graphql context initialization.

eric-burel commented 3 years ago

Best one-liner PR of 2021 yet

eric-burel commented 3 years ago

Don't you need the request as parameter somewhere? Except if it is already in context.req, but not sure if that's clear enough

Apollinaire commented 3 years ago

request is already in context.req, so i thought it was useless to add it. However, now that you mention it, it would be a good idea to add it in, simply as a guarantee to pass it to every callback.