3

I have successfully set up Graph.cool Auth0 authentication and created a User through Relay as described here.

Next I'd like to actually query graph.cool on behalf of this user. As a first step, I simply manually modified the Relay setup to specify the same auth token as was used to create the User in the first place (through the idToken on type AUTH_PROVIDER_AUTH0):

Relay.injectNetworkLayer(
  new Relay.DefaultNetworkLayer(process.env.GRAPHQL_ENDPOINT, {
    headers: {
      Authorization: 'Bearer XXX.YYY.ZZZ',
    },
  })
);

However, the app stops rendering and I just get a console warning RelayPendingQueryTracker.js:153 Server response was missing for query Index. Any hints?

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958

1 Answers1

3

When calling the signinUser or createUser mutation, a Graphcool token is returned in the payload. https://www.graph.cool/docs/faq/graphcool-session-user-goij0cooqu

This is the token you need to use in the Authorization header instead of the Auth0 idToken.

Maybe it can also be a help to take a look at how we do it in the dashboard https://github.com/graphcool/dashboard/blob/master/src/views/LoginView/LoginView.tsx

Hope this helps!

marktani
  • 7,578
  • 6
  • 37
  • 60
sorenbs
  • 749
  • 4
  • 7