1
我收到以下错误:GraphQL错误 - 错误:只能创建一个列表的GraphQLType却得到了:对象对象]
Error: Can only create List of a GraphQLType but got: [object Object].
但我传递一个GraphQLType。
这是触发错误的文件。
```
var GraphQL = require('graphql');
var BotType = require('../types/bot-type');
var Datastore = require('../../datastores/memory-datastore')
const BotListType = new GraphQL.GraphQLList(BotType);
module.exports = new GraphQL.GraphQLObjectType({
type: BotListType,
resolve: function(object) {
return object.bots.map(Datastore.getBot)
}
})
```
这是关于
```
var GraphQL = require('graphql');
var RelayQL = require('graphql-relay');
var Node = require('../node');
var IntegrationListField = require('../fields/integration-list-field')
const BotType = new GraphQL.GraphQLObjectType({
name: 'Bot',
fields: {
id: RelayQL.globalIdField('Bot'),
name: { type: GraphQL.GraphQLString },
integrations: IntegrationListField
},
interfaces: [ Node.nodeInterface ]
});
module.exports = BotType
```
经过一番调查看来'require'是在空的对象拉动。 –
尝试用函数替换你的'field'对象。而不是 'fields:{...}'将它定义为'fields:()=>({...})'。 – LordDave