GatsbyCentral / gatsby-awesome-pagination

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

Variables "$skip" and "$limit" of required type "Int!" were not provided. #39

Closed AlmaJaneiro closed 4 years ago

AlmaJaneiro commented 4 years ago

Hi everyone !!!

I'm new on gatsby heheh so maybe I have a dummy mistake,

I don't know what is happening, because in gatsby develop everything is working fine,

but in gatsby build it is not working, so I don't know what else to do,

I tried with rm -r .cache and deleting node modules and reinstalling haha

this is my code :

gatsby-node.js

Captura de Pantalla 2020-05-08 a la(s) 1 23 17 a m

blog.js

Captura de Pantalla 2020-05-08 a la(s) 1 23 25 a m

there is something wrong with my query ?

Thanks in advance !!

chmac commented 4 years ago

I suggest posting on stack overflow. We're not able to provide support here.

If you discover a bug in the plugin, will be happy to try and fix.

I also recommend posting an error message, or a very precise definition of what you think is not working on your gatsby build output.

I'll close this issue now as we don't provide Q&A support here.

graysonhicks commented 3 years ago

Hi @AlmaJaneiro and whoever else may find this. I am not familiar with that plugin, but I think the issue is that you are calling paginate and createPage. It looks like paginate receives the createPage function and does that for you, so I think when you call createPage with that template, the query there expects $limit, $skip, etc. to be there via context, but they aren't. Can you try removing the createPage calls for the BlogPosts?

graysonhicks commented 3 years ago

An update on the above. In one case I was seeing the createPage and paginate using the same component causing this issue. Another case I found was having the component be in the pages directory instead of the templates directory.

Wrong:

paginate({
    createPage,
    items: blogPosts,
    itemsPerPage: 3,
    pathPrefix: "/blogs",
    // Note /pages/ here
    component: path.resolve(`./src/pages/blogs.js`),
  })

Correct:

paginate({
    createPage,
    items: blogPosts,
    itemsPerPage: 3,
    pathPrefix: "/blogs",
    // Note /templates/ here
    component: path.resolve(`./src/templates/blogs.js`),
  })

The issue is that if the component is under pages then the query will attempt to run without the required context.