3

With this kind of request, pulling post data from Contentful with GraphQL using gatsby-source-contentful plugin, looking for a way to access the post published date (post.sys.publishedAt) or updatedAt !

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

}

wabdsgn
  • 71
  • 5

1 Answers1

2

source-contentful plugin does not include the sys property in the GraphQL schema. it only includes the fields and the id.As a workaround, you can add a field that holds the date and it will be available for you in graphQL.

I hope this help

Edit ---------------

I just submitted a PR adding these options to gatsbyjs https://github.com/gatsbyjs/gatsby/pull/2398 You can now access updatedAt and createdAt properties.

Khaled Garbaya
  • 1,479
  • 16
  • 20