2016-01-24 11 views
1

我正在关注Relay 101: Building A Hacker News Client Tutorial。AssertionError:relay-101/index.js:getBabelRelayPlugin():预期的模式是一个带有__schema的对象

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

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."}]} 

但我不知道为什么会发生这种情况? 这个错误为什么会发生?

任何方向将不胜感激。

+0

现在我试图与最终的源https://github.com/clayallsopp/relay-101与我的比较。 – ruseel

回答

0

我在babelRelayPlugin.js中犯了一个错误,在s trospectionQuery而不是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 
    } 
}); 
相关问题