title: I am unable to create pages dynamically using Gatsby
body: <p>I am using Gatsby on my project. I am trying to create a page which needs pagination.</p>
  <p>I followed this <a href="https://www.gatsbyjs.org/docs/adding-pagination/" rel="nofollow noreferrer">https://www.gatsbyjs.org/docs/adding-pagination/</a> and this other guide <a href="https://nickymeuleman.netlify.app/blog/gatsby-pagination/" rel="nofollow noreferrer">https://nickymeuleman.netlify.app/blog/gatsby-pagination/</a> and how to do it but it is not working.</p>
  <p>I have multiple queries on <code>gatsby-node.js</code>:</p>
  <pre><code>exports.createPages = async ({ graphql, actions, page }) =&gt; {
      const { createPage } = actions
      const shop = path.resolve(&quot;./src/templates/shop.js&quot;)
      const productPageTemplate = path.resolve(&quot;./src/templates/ProductPage/index.js&quot;)
      
      const singleProduct = await graphql(`
        query {
          allShopifyProduct {
            edges {
              node {
                handle
              }
            }
          }
        }
      `)
      
      // This is the query which I need for the pagination
      // Create shop pages
      const products = await graphql(`
        query allShopifyProduct($skip: Int!, $limit: Int!) {
          allShopifyProduct(sort: { fields: [createdAt], order: DESC }
            skip: $skip
            limit: 5
          ) {
            edges {
              node {
                id
                title
                handle
              }
            }
          }
        }
      `)
      
      const posts = products.data.allShopifyProduct.edges  
      
      const postsPerPage = 5
      const numPages = Math.ceil(posts.length / postsPerPage)
      
      Array.from({ length: numPages }).forEach((_, i) =&gt; {
        const withPrefix = (pageNumber) =&gt;
          pageNumber === 1 ? `/shop` : `/shop/${pageNumber}`
        const pageNumber = i + 1
        createPage({
          path: withPrefix(pageNumber),
          component: shop,
          context: {
            limit: postsPerPage,
            skip: i * postsPerPage,
            current: pageNumber,
            total: numPages,
            hasNext: pageNumber &lt; numPages,
            nextPath: withPrefix(pageNumber + 1),
            hasPrev: i &gt; 0,
            prevPath: withPrefix(pageNumber - 1),
          },
        })
      })
      
      // Adding the single product stuff to show my multiple queries
      singleProduct.data.allShopifyProduct.edges.forEach(({ node }) =&gt; {
        createPage({
          path: `/product/${node.handle}/`,
          component: productPageTemplate,
          context: {
            // Data passed to context is available
            // in page queries as GraphQL variables.
            handle: node.handle,
          },
        })
      })
  })
  </code></pre>
  <p>This is my React component:</p>
  <pre><code>import React from &quot;react&quot;
  import { graphql, Link } from &quot;gatsby&quot;
  
  // Components
  import ProductGrid from &quot;@components/ProductGrid/productGrid&quot;
  
  const Shop = ({ data: { allShopifyProduct }, pageContext }) =&gt; {
    return (
      &lt;div className=&quot;product-grid&quot;&gt;
        &lt;ProductGrid allShopifyProduct={allShopifyProduct}
        /&gt;
        {!pageContext.hasPrev &amp;&amp; (
          &lt;Link to={pageContext.prevPage} rel=&quot;prev&quot;&gt;
            ← Previous Page
          &lt;/Link&gt;
        )}
        {!pageContext.hasNext &amp;&amp; (
          &lt;Link to={pageContext.nextPage} rel=&quot;next&quot;&gt;
            Next Page →
          &lt;/Link&gt;
        )}
      &lt;/div&gt;
    )
  }
  
  export default Shop
  
  export const query = graphql`
    query allShopifyProduct($skip: Int!, $limit: Int!) {
      allShopifyProduct(
        sort: { fields: [createdAt], order: DESC }
        skip: $skip
        limit: $limit
      ) {
        edges {
          node {
            id
            title
            handle
          }
        }
      }
    }
  `
  </code></pre>
  <p>And it keeps throwing errors like these:</p>
  <pre><code> ERROR #85927  GRAPHQL
  
  There was an error in your GraphQL query:
  
  Variable &quot;$skip&quot; is never used in operation &quot;allShopifyProduct&quot;.
  
  See if $skip has a typo or allShopifyProduct doesn't actually require this variable.
  
  File: gatsby-node.js:74:26
  
  
   ERROR #85927  GRAPHQL
  
  There was an error in your GraphQL query:
  
  Variable &quot;$limit&quot; is never used in operation &quot;allShopifyProduct&quot;.
  
  See if $limit has a typo or allShopifyProduct doesn't actually require this variable.
  
  File: gatsby-node.js:74:26
  
  
   ERROR #11321  PLUGIN
  
  &quot;gatsby-node.js&quot; threw an error while running the createPages lifecycle:
  
  Cannot read property 'allShopifyProduct' of undefined
  
    108 |   `)
    109 |
  &gt; 110 |   const posts = products.data.allShopifyProduct.edges
        |                               ^
    111 |
  
  File: gatsby-node.js:110:31
  
  
  
    TypeError: Cannot read property 'allShopifyProduct' of undefined
  
    - gatsby-node.js:110 Object.exports.createPages
      /Users/marcelo/Work/gatsby-on-demand/gatsby-node.js:110:31
  
  failed createPages - 0.113s
  
  </code></pre>
  <p>If I run these exact queries on my GraphiQL interface everything work perfectly:
  <a href="https://i.stack.imgur.com/pkm1t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pkm1t.png" alt="enter image description here" /></a></p>
  <p>Any ideas on where could I be failing at?</p>