在Gatsby GraphQL中检索内容ID
我使用graghql从gatsby-node.js中的contentful查询数据在Gatsby GraphQL中检索内容ID,graphql,gatsby,contentful,Graphql,Gatsby,Contentful,我使用graghql从gatsby-node.js中的contentful查询数据 exports.createPages = async ({ graphql, actions }) => { ... const result = await graphql( ` { allContentfulArticle( sort: { order: DESC, fields: date }, limit: 20
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不匹配。例如,一个返回id是32015820-f327-5085-b5c0-27146850a8f5
,但我条目的id是2pljYDQAJ8umcV5po5TDK8
当我使用contentful交付api时,我可以获得正确的id,那么,发生了什么?谁更改id的格式?如何获得正确的id?我使用的contentful插件是gatsby source contentful。如果您在
http://localhost:8000/___graphql
您可以看到整个GraphQL架构
正如您所看到的,每个项目都有两个ID字段:justID
是盖茨比ID,contentful\u ID
是contentful ID。因此contentful\u ID
是您要查找的
您没有真正指定要检索的
id
的位置,至少在上面显示的查询中是这样。因此,也许通过查看模式来找出如何检索特定项会有所帮助。你是我的英雄,谢谢,我只是忘了检查。