【发布时间】:2020-11-02 10:43:11
【问题描述】:
我在 gatsby-node.js 中使用 graghql 从内容中查询数据
exports.createPages = async ({ graphql, actions }) => {
...
const result = await graphql(
`
{
allContentfulArticle(
sort: { order: DESC, fields: date },
limit: 2000
) {
totalCount,
edges {
node {
id
title
excerpt
date
tag
content{
content
}
}
}
}
}
`
)
})
节点中返回的 id 与我的内容条目的 id 不匹配。比如一个return id是32015820-f327-5085-b5c0-27146850a8f5,但是我entry的id是2pljYDQAJ8umcV5po5TDK8
当我使用内容交付 api 时,我可以获得正确的 id,那么,发生了什么?谁更改了 id 的格式?如何获得正确的身份证?我使用的内容插件是 gatsby-source-contentful。
【问题讨论】:
-
您并没有真正指定您想要检索的
id的任何位置,至少在您上面显示的查询中。因此,也许查看架构以找出如何检索特定项目会有所帮助。
标签: graphql gatsby contentful