我有一个看起来像这样的GraphQL查询
{
allContentfulDocuments {
edges {
node {
documents {
id
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
有什么方法可以将edgesand node层展平,使其变得本质上类似于此查询:
{
allContentfulDocuments {
documents {
id
}
}
}
Run Code Online (Sandbox Code Playgroud)
Nic*_*rdy -2
您可以通过使用来实现这一点Array.prototype.map。
data.allContentfulDocuments.edges.map(edge =>
edge.node.documents.map(document => ({ id: document.id }))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1266 次 |
| 最近记录: |