【问题标题】:Apollo: Extending type from remote schemaApollo:从远程模式扩展类型
【发布时间】:2018-10-09 06:22:35
【问题描述】:

我目前有多个运行 Apollo 的 GraphQL 服务,并创建了一个使用远程模式拼接的“网关”服务,以便为我提供一个访问端点。

在我的网关服务中,我希望扩展远程类型以创建拼接模式之间的引用。

const linkTypeDefs = `
    extend type User {
        profile: Profile
    }

    extend type Profile {
        user: User
    }`;

const schema = mergeSchemas({
    schemas: [userSchema, profileSchema, linkTypeDefs],
    resolvers: /* Resolvers */
});

但我似乎收到以下错误:

GraphQLError:无法扩展类型“用户”,因为它在现有架构中不存在。

我已经仔细检查了“用户”和“个人资料”类型存在,我可以从 Gateway Graphiql 查询它们。

为了扩展从远程模式合并的类型,我需要采取什么特定步骤吗?

【问题讨论】:

    标签: graphql apollo graphql-js react-apollo apollo-client


    【解决方案1】:

    我最终通过意识到 userSchemaprofileSchema 都在返回一个承诺来解决这个问题。

    我等待这些返回值,这为我解决了问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-15
      • 2013-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多