【发布时间】:2018-05-06 19:58:28
【问题描述】:
我正在研究 GraphQL,我想了解 GraphlQL 将如何执行查询谎言:
poc (id: $id) {
tradingName
id
products{
id
title
imageUrl
productVariants {
title
}
images{
url
}
}
}
在resolve_all_products 上,我将只查询产品的id。
例如select * from products where poc_id=10
在resolve_product_variants 节点上,我将查询具有特定产品ID 的所有产品变体。
例如select * from product_variants where product_id=X
现在假设我有 20 种产品,每种产品都有 2 个产品变体。 因此,我将进行一次查询以获取所有产品 (20),然后再获取 20 个。他们每个人都将从特定产品中获取所有产品变体 (2)。
因此,我将执行 21 个查询,而不是单个连接查询。我对吗? 有没有办法防止这种情况发生?
【问题讨论】:
标签: graphql graphql-js