lvarayut / relay-fullstack

:point_up::running: Modern Relay Starter Kit - Integrated with Relay, GraphQL, Express, ES6/ES7, JSX, Webpack, Babel, Material Design Lite, and PostCSS
https://lvarayut.github.io/relay-fullstack/
MIT License
985 stars 126 forks source link

user authentification #13

Closed keon closed 8 years ago

keon commented 8 years ago

How should we implement user authentification in GraphQL? Most practices I saw are RESTful (for user auth) + GraphQL (for general use)

lvarayut commented 8 years ago

You could inject your own DefaultNetworkLayer as following:

Relay.injectNetworkLayer(
  new Relay.DefaultNetworkLayer('http://localhost:3000/graphql', {
    headers: {
      Authorization: 'Bearer ' + token
    }
  })
);

Take a look at this awesome article.