prismicio-community / gatsby-starter-prismic-blog

Blog project with Gatsby & Prismic
https://gatsby-starter-prismic-blog.vercel.app
Apache License 2.0
40 stars 23 forks source link

post.js always returns blank (empty array) #1

Closed michaelpumo closed 5 years ago

michaelpumo commented 5 years ago

I was following this guide and managed to get things running (after some other odd errors): https://intercom.help/prismicio/en/articles/2933292-sample-blog-with-api-based-cms-gatsby-js

However, when navigating to a blog post after running gatsby develop, it simply shows a blank page. In the Prismic repository, all fields are filled in as expected.

Logging props.data.prismic.allPosts.edges in post.js reveals an empty array. No matter what post is navigated to, it's simply blank.

I feel like there's an issue with the setup/query that fetches the post. It's almost as if the UID is not getting passed correctly?

If I try the query in the GraphiQL playground with the post UID it works but in the template, the exact same query does not return the post.

query BlogPostQuery($uid: String!) {
  prismic {
    allPosts(uid: $uid) {
      edges {
        node {
          _meta {
            id
            uid
            type
          }
          title
          date
          body {
            __typename
            ... on PRISMIC_PostBodyText {
              type
              label
              primary {
                text
              }
            }
            ... on PRISMIC_PostBodyQuote {
              type
              label
              primary {
                quote
              }
            }
            ... on PRISMIC_PostBodyImage_with_caption {
              type
              label
              primary {
                image
                caption
              }
            }
          }
        }
      }
    }
  }
}

See the screenshot:

Screenshot 2019-10-13 at 19 20 21

Any ideas what's going on here? On the home page, the post is listed just fine (so of course it does exist).

There are no errors in the web console nor the terminal.

Thanks.

hypervillain commented 5 years ago

Hello @michaelpumo, sorry that you encountered such an issue.

Can you try updating gatsby-source-prismic-graphql to version 3.4.0-beta.2?

michaelpumo commented 5 years ago

Hello @michaelpumo, sorry that you encountered such an issue.

Can you try updating gatsby-source-prismic-graphql to version 3.4.0-beta.2?

Okay, this solved it. Any ideas why, or what was wrong?

Thank you!

hypervillain commented 5 years ago

Actually, I'm not sure what is wrong with your version but I noticed some issues were corrected in the beta version. If you're unsure of which version to use, please have a look here: https://www.npmjs.com/package/gatsby-source-prismic-graphql but I believe always using the beta versions should work just fine.

Let me know if you need more help of course