Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove schema.addToContext #524

Open
jasonkuhrt opened this issue Mar 22, 2020 · 0 comments
Open

Remove schema.addToContext #524

jasonkuhrt opened this issue Mar 22, 2020 · 0 comments
Labels
scope/schema-context type/feat Add a new capability or enhance an existing one

Comments

@jasonkuhrt
Copy link
Member

jasonkuhrt commented Mar 22, 2020

Perceived Problem

  • schema.addToContext encourages writing middleware where it should NOT be
  • schema.addToContext is an API awkwardly between server/schema components
  • schema.addToContext functionally overlaps with middleware in some ways

Idea

  • Embrace that context is a core data concept of a Nexus app

  • Remove it in favour of the proposed middleware system server middleware #523

  • Example

     server.middleware((request, response, context) => {
       context.foo = 'bar'
     })
  • Global context can be addable like so:

     import { context } from 'nexus'
     
     context.foo = 'bar'
@jasonkuhrt jasonkuhrt added type/feat Add a new capability or enhance an existing one scope/schema-context labels Mar 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope/schema-context type/feat Add a new capability or enhance an existing one
Projects
None yet
Development

No branches or pull requests

1 participant