【问题标题】:graphql mergeSchemas from GraphQLObjectType schemas来自 GraphQLObjectType 模式的 graphql mergeSchemas
【发布时间】:2019-08-19 11:48:52
【问题描述】:

我是 graphql 的新手,所以我遇到了一些问题。 基于 nodeJS 的服务器,带有 express 包。我正在用 GraphQLObjectType 表示法为 Apollo Graphql 编写模式。 当我想将两个模式合并为一个时,我使用 graphql-tools npm 包中的 mergeSchemas 方法,并在合并时遇到了一些错误。谁能指出我做错了什么?

const { mergeSchemas } = require('graphql-tools');
const { GraphQLSchema } = require('graphql');

const queryType = require('./queryType');
const eventMutations = require('./eventMutations');
const userMutations = require('./userMutations');

const mutationType = mergeSchemas({
  schemas: [eventMutations, userMutations],
});

module.exports = new GraphQLSchema({
  query: queryType,
  mutation: mutationType,
});

每一个eventMutations,userMutations都是GraphQLObjectType

错误是:

Invalid schema passed

mergeSchemas({...

有什么想法吗?

【问题讨论】:

    标签: node.js graphql apollo graphql-tools


    【解决方案1】:

    问题是我想合并 GraphQLObjectType 但不是真正的 GraphQLSchema。 因此解决方案是为用户和事件创建 GraphQLSchema,然后将它们完美地合并在一起。

    【讨论】:

      猜你喜欢
      • 2019-03-02
      • 2017-11-29
      • 2017-09-19
      • 2021-02-25
      • 2019-06-22
      • 2018-02-08
      • 2019-08-20
      • 2020-09-11
      • 2020-10-15
      相关资源
      最近更新 更多