Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
create gatsby-node pages based on a graphql query

I want to createPage based on some queries I am using , this is my query in my gatsby-node.js :

{
      allPrismicLastPosts {
        nodes {
          data {
            blogs {
              blog {
                document {
                  ... on PrismicBlog {
                    uid
                  }
                  ... on PrismicCulture {
                    uid
                    }
                  }
                }
              }
            }
          }
        }
      }
      allPrismicMainBlogs {
        nodes {
          data {
            blogs {
              blog {
                document {
                  ... on PrismicBlogMain {
                    uid
                  }
                }
              }
            }
          }
        }
      }
}

what I want from this query is the uid field , and Since this query returns this JSON format :

allPrismicMainBlogs": {
      "nodes": [
        {
          "data": {
            "blogs": [
              {
                "blog": {
                  "document": {
                    "uid": "main02",
                     .
                     .
                     .
}

I've tried this to fetch the uid :

  postPages.data.allPrismicLastPosts.nodes.forEach((page) => {
    page.data.blogs.forEach((article)=>
    {
      createPage({
        path: article.blog.document.data.uid,
        component: path.resolve(__dirname, 'src/templates/post.js'),
        context: {
          id: page.id,
        },
      })
    }
    )
  })

I cannot get the uid because I am using allPrismicLastPosts but instead I want all the queries , so how can I fix this to display all the uid

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think you are trying to access directly to:

article.blog.document.uid

Applied to your code:

postPages.data.allPrismicLastPosts.nodes.forEach((page) => {
  page.data.blogs.forEach((article) => {
    createPage({
      path: article.blog.document.uid,
      component: path.resolve(__dirname, "src/templates/post.js"),
      context: {
        id: page.id,
      },
    });
  });
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!