【问题标题】:Issuing authenticated queries with Graphcool使用 Graphcool 发出经过身份验证的查询
【发布时间】:2017-03-05 11:34:47
【问题描述】:

我已成功设置Graph.cool Auth0 身份验证并按照here 所述通过中继创建用户。

接下来,我想代表该用户实际查询 graph.cool。作为第一步,我只是手动修改了中继设置,以指定与最初用于创建用户的相同的身份验证令牌(通过AUTH_PROVIDER_AUTH0 类型的idToken):

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

但是,应用程序停止渲染,我只收到控制台警告 RelayPendingQueryTracker.js:153 Server response was missing for query Index。有什么提示吗?

【问题讨论】:

    标签: authentication graphql auth0 relayjs graphcool


    【解决方案1】:

    当调用 signinUser 或 createUser 突变时,有效负载中会返回一个 Graphcool 令牌。 https://www.graph.cool/docs/faq/graphcool-session-user-goij0cooqu

    这是您需要在 Authorization 标头中使用的令牌,而不是 Auth0 idToken。

    也许在仪表板https://github.com/graphcool/dashboard/blob/master/src/views/LoginView/LoginView.tsx看看我们是如何做到这一点的@

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-25
      • 2016-04-29
      • 2011-12-22
      • 2020-11-14
      • 1970-01-01
      • 2019-07-02
      相关资源
      最近更新 更多