apollographql / apollographql/fullstack-tutorial
[Question]Why are no `async` on some resolver methods?
- 主要语言
- TypeScript
- 星标
- 1.2k
- 派生
- 808
- PR 合并指标
- 30 天内没有已合并 PR
描述
Hi, I'm very new to Apollo graphql and reading through the tutorial.
I noticed that `launch` method in resolver.js does not have `async` and wondering why even though the request is asynchronous. In fact, if I add async it works as expected. Could someone tell me why `async` is not required in this case?
```
module.exports = {
Query: {
launches: async (_, __, { dataSources }) =>
dataSources.launchAPI.getAllLaunches(),
launch: (_, { id }, { dataSources }) => // no async
dataSources.launchAPI.getLaunchById({ launchId: id }),
me: async (_, __, { dataSources }) =>
dataSources.userAPI.findOrCreateUser(),
},
};
```
贡献指南
这个仓库没有索引到贡献指南
调研方向
从 resolver.js 和 issue 中展示的 Query resolver 开始,然后检查 dataSources.launchAPI.getLaunchById 以及 launches 和 me 方法。记录 launch resolver 不使用 async 编写的原因,并让面向 tutorial 读者的解释清晰易懂;当在 tutorial 上下文中回答了关于 async 的问题时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, node.js
- 领域
- documentation
- Issue 类型
- 文档
- 难度
- 1/5
- 预计耗时
- 1 小时以内
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 35/100