How to Build a Static Blog with Gatsby and Strapi

In this step-by-step guide, you will learn how to harness the power of Gatsby, a blazing-fast static site generator, and Strapi, a composable CMS, to create a dynamic yet performant blog.


This is a companion discussion topic for the original entry at https://strapi.io/blog/how-to-build-a-static-blog-with-gatsby-and-strapi

Hi there I am following the tutorial and I am getting stuck with the following graphql query. Have I done done something wrong?

query ($id: String) {
    strapiPost(id: {eq: $id}) {
      author {
        avatar
        name
      }
      category {
        name
        slug
      }
      content {
        data {
          childMarkdownRemark {
            html
          }
        }
      }
      cover
      date(formatString: "MMMM D, YYYY")
      description
      slug
      title
    }
  }
"Cannot query field \"data\" on type \"STRAPI_POSTContent\".",

I got a valid response when running that query.

Make sure you have the backend strapi server running when you attempt to query it from the gatsby graphiql page.

While creating the Post > content field, you need to select field type as ‘Rich text (Markdown)’. The error you are getting indicates that you have likely selected ‘Rich text (Blocks)’ instead. Delete the field and add it again with the correct type, and check again.