【问题标题】:How to extend an existing type using graphql-js classes (no SDL)?如何使用 graphql-js 类(无 SDL)扩展现有类型?
【发布时间】:2019-04-10 12:37:25
【问题描述】:

使用 SDL,我可以做到这一点:

extend type Query {
   something: String!
}

在通过内置 GraphQLObjectType 类构建类型时,我该怎么做?

它似乎没有在任何地方记录。

【问题讨论】:

    标签: graphql graphql-js


    【解决方案1】:

    This library 可能有帮助吗?

    做完了

    const AuthorTC = TypeComposer.create({
      name: 'Author',
      fields: {
        id: 'Int!',
        firstName: 'String',
        lastName: 'String',
      },
    });
    

    然后你就可以addFields

    AuthorTC.addFields({ ... })
    

    并获取GraphQLObjectType

    AuthorTC.getType()
    

    【讨论】:

      猜你喜欢
      • 2018-08-01
      • 2019-01-07
      • 2019-03-13
      • 1970-01-01
      • 2018-11-29
      • 2021-11-03
      • 1970-01-01
      • 2020-02-28
      • 2019-02-14
      相关资源
      最近更新 更多