Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Graphql 如何使用Contentful从Gatsby中的查询中检索发布的发布日期?_Graphql_Contentful_Gatsby - Fatal编程技术网

Graphql 如何使用Contentful从Gatsby中的查询中检索发布的发布日期?

Graphql 如何使用Contentful从Gatsby中的查询中检索发布的发布日期?,graphql,contentful,gatsby,Graphql,Contentful,Gatsby,对于这种请求,使用gatsby source Contentful插件从Contentful和GraphQL中提取post数据,寻找访问post发布日期(post.sys.publishedAt)或updatedAt的方法 { contentfulPost(id: { eq: 'postId' }) { --> publishedAt ? title image { responsiveResolution(width: 500, height: 500)

对于这种请求,使用
gatsby source Contentful
插件从ContentfulGraphQL中提取post数据,寻找访问post发布日期(post.sys.publishedAt)或updatedAt的方法

 {
  contentfulPost(id: { eq: 'postId' }) {
   --> publishedAt ?
   title
   image {
    responsiveResolution(width: 500, height: 500) {
      src
      srcSet
      height
      width
    }
  }

}源内容插件在GraphQL架构中不包含
sys
属性。它只包括字段和id。作为一种解决方法,您可以添加一个保存日期的字段,它将在graphQL中为您提供

我希望这有帮助

编辑---------------

我刚刚提交了一份PR,将这些选项添加到gatsbyjs中
您现在可以访问
updatedAt
createdAt
属性。

Thanx作为您的答案。那么这是否意味着编辑必须填写此字段以获得发布日期,或者您知道如何使用发布的数据自动完成此字段?我创建了一个关于将
sys
字段添加到GraphQL Thanx的问题!这可能是有用的博客文章!这周我会尽量找时间来做的