title: Getting an "Exported queries are only executed for Page components." in Gatsby when trying to generate pages
body: <p>This seems to be a relatively common problem. I am trying to generate blog post pages but am experiencing this error and the pages show a 404 on load. Which means that they are not being generated.</p>
  <p>Here is my code for the <code>gatsby.node.js</code> file:</p>
  <pre><code>exports.createPages = async ({ graphql, useStaticQuery, actions: { createPage } }) =&gt; {
      const postQuery = graphql(`
        {
          gcms {
            posts(where: { stage: PUBLISHED }) {
                id
              slug
            }
          }
        }
      `);
  
      const {
          gcms: { posts },
        } = useStaticQuery(postQuery);
    
      posts.forEach(({ id, slug }) =&gt;
        createPage({
          path: `/blog/${slug}`,
          component: require.resolve(`./src/templates/PostPage.js`),
          context: {
              id: id,
              slug: slug,
          },
        })
      );
    };
  </code></pre>
  <p>And my code for the blog post <code>PostPage.js</code> file:</p>
  <pre><code>/* eslint-disable react/prop-types */
  import React from 'react';
  import { graphql } from 'gatsby';
  import Layout from &quot;../components/layout&quot;;
  //import galaxy from &quot;../images/galaxy.jpg&quot;;
  import SEO from &quot;../components/seo&quot;;
  
  export const postPageQuery = graphql`
    query PostPageQuery($id: ID!) {
      gcms {
        post(where: { id: $id }) {
          title
            slug
            excerpt
            postContentMarkdown
            tags
            author {
              name
              biography
            }
            seo {
              title
              description
              keywords
            }
        }
      }
    }
  `;
  
  const PostPage = ({data: {post}}) =&gt; {
      return (
          &lt;Layout&gt;
              &lt;SEO
                  keywords={[
                      `ui`,
                      `ux`,
                  ]}
                  title=&quot;Blog&quot; /&gt;
              {post.slug}
          &lt;/Layout&gt;
      );
  };
  
  export default PostPage;
  </code></pre>