javascript - 自动生成 GraphQL API 接口
问题描述
我正在使用 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',
});
是否有现有的系统可以做到这一点?
解决方案
到目前为止,我在研究中看到的最强大的东西是graphql-sequelize,它是 Sequelize 接口的一个 graphql 数据库后端,它是 Node.js 目前更流行的 ORM 之一。
推荐阅读
- typescript - 打字稿:如何增加`export = Joi.Root`
- oracle - 如何将 INSTR (Oracle) 转换为 STRPOS (PostgreSQL)?
- amqp - 如何使用 .NET 客户端应用程序使用 AMQPNetLite 设置 PRE_ACKNOWLEDGE 模式
- crossfilter - 如何在 amCharts 的简单柱形图中实现多项选择
- php - 使用 PHP 的不同值
- vb6 - 需要旧的 Sheridan Data Widget Controls 3.13
- c++ - 为什么断点显示我的数组的第二个值是一个很大的数字?额外的学分工作
- python - pm2 在 scripts.sh 上因太多不稳定的重启而崩溃
- c++ - 关于获取事件日志使用 EvtOpenSession (为什么用任何文本填充域参数都可以成功?)
- javascript - 无论如何我可以使用 Yup.js 来验证排序数组吗?