【问题标题】:Autogenerate GraphQL API interface自动生成 GraphQL API 接口
【发布时间】:2020-01-03 20:24:58
【问题描述】:

我正在使用 Apollo 访问 GraphQL 端点。我在文件中有完整的架构。假设架构如下:

type Widget {
    widgetId: ID!
    name: String
}

type Query {
    listWidgets: [Widget!]!
}

type Mutation {
    updateWidget(
        widgetId: ID!
        name: String
    ): Widget!
}

我想创建一个具有如下接口的 API 对象:

const api = MyApi(endpoint);

const widgets = await api.listWidgets();

const modifiedWidget = await api.updateWidget({
    widgetId: 'myId',
    name: 'My widget',
});

是否有现有的系统可以做到这一点?

【问题讨论】:

    标签: javascript node.js graphql apollo-client


    【解决方案1】:

    到目前为止,我在研究中看到的最强大的东西是 graphql-sequelize,它是 Sequelize 接口的 graphql 数据库后端,是 Node.js 目前更流行的 ORM 之一。

    【讨论】:

      猜你喜欢
      • 2018-09-04
      • 2011-07-03
      • 2020-11-16
      • 2011-03-27
      • 1970-01-01
      • 2020-12-08
      • 2021-01-08
      • 2019-04-05
      相关资源
      最近更新 更多