【发布时间】:2017-01-11 19:10:25
【问题描述】:
假设我们有以下 graphql 架构:
type Author : Object {
id: ID!
name: String,
books: [Book]
}
type Book : Object {
id: ID!
title: String
authorId: Int
author: Author
}
然后进行如下查询:
{
books: {
id
title
author { id name }
}
}
例如,如果我们有 10 本书,那么我们将得到 10 个作者查询,因为将为每本书调用 resolve 函数:
select id, name from author where id = 123
我们可以将所有作者查询作为单个查询执行:
select id, name from author where id in (123, 456, 789, 1011)
是否有一些可行的解决方案、最佳实践、技术或可以帮助实现这一目标的东西?
【问题讨论】:
标签: graphql graphql-js