【问题标题】:AssertionError: relay-101/index.js: getBabelRelayPlugin(): Expected schema to be an object with a `__schema`AssertionError:relay-101/index.js:getBabelRelayPlugin():预期模式是一个带有`__schema`的对象
【发布时间】:2016-01-25 00:03:50
【问题描述】:

我正在关注Relay 101: Building A Hacker News Client 教程。

但是在这个过程中我得到了错误

AssertionError: relay-101/index.js: getBabelRelayPlugin():
Expected schema to be an object with a `__schema` property.
at getSchema (/Users/ruseel/p/spike/relay-101/node_modules/babel-relay-plugin/src/getBabelRelayPlugin.js:224:3)
at NodePath.Plugin.visitor.TaggedTemplateExpression (/Users/ruseel/p/spike/relay-101/node_modules/babel-relay-plugin/src/getBabelRelayPlugin.js:104:26)
...

经过一番挖掘(getBabelRelayPlugin.js 中的console.log),我注意到getBabelRelayPlugin.js 中的自省变量

   const introspection = typeof schemaProvider === 'function' ?
    schemaProvider() :
    schemaProvider;

是这样的。

{"errors":[{"message":"Must provide query string."}]}

但我不知道为什么会这样? 为什么会出现这个错误?

任何方向将不胜感激。

【问题讨论】:

标签: relay


【解决方案1】:

我在 babelRelayPlugin.js 中打了一个错字,在 strospectionQuery 而不是 introspectionQuery。

var babelRelayPlugin = require('babel-relay-plugin');
var introspectionQuery = require('graphql/utilities').introspectionQuery;
var request = require('sync-request');

var graphqlHubUrl = 'http://www.graphqlhub.com/graphql';
var response = request('GET', graphqlHubUrl, {
  qs: {
    query: introspectionQuery
  }
});

【讨论】:

    猜你喜欢
    • 2019-02-16
    • 2020-09-03
    • 1970-01-01
    • 1970-01-01
    • 2019-03-17
    • 1970-01-01
    • 2020-05-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多