GatsbyCentral / gatsby-awesome-pagination

An opinionated, more awesome approach to pagination in Gatsby
MIT License
110 stars 27 forks source link

Passing context #46

Closed abdullahe closed 4 years ago

abdullahe commented 4 years ago

Hi,

I'm a newbie, and couldn't figure out how to pass context within paginate and createPagePerItem. I would be glad if you can help me.

Here is the error:

There was an error in your GraphQL query:

Variable "$id" of required type "String!" was not provided.

>  1 | query BlogQuery($id: String!) {
     |                 ^
   2 |   page: mdx(id: {eq: $id}) {
   3 |     frontmatter {
   4 |       lang
   5 |       title
   6 |       description
   7 |       templateKey
   8 |       tags
   9 |     }
  10 |     body
  11 |   }

Here is the part in gatsby-node.js :

paginate({
      createPage,
      items: blogPosts_en,
      component: blogIndex,
      itemsPerPage: 1,
      itemsPerFirstPage: 1,
      pathPrefix: "/news-insight",
      context: {
        locale: "node.frontmatter.lang",
      },
    });

createPagePerItem({
      createPage,
      items: blogPosts_en,
      component: blogPost,
      itemToPath: "node.fields.slug",
      itemToId: "node.id",
      context: {
        locale: "node.frontmatter.lang",
        id: "node.id",
      },
    });
chmac commented 4 years ago

I'm afraid we don't provide free-of-charge technical support here. I recommend trying stack overflow.