wp-graphql/gatsby-wpgraphql-blog-example

pagination performance when +10k articles

zalog opened this issue · 1 comments

zalog commented

This is more like a question.

What about if we have a lot of posts, let's say more that 10k with 10 per page and the user arrives from google on one of our last, blog/page/900. How this will perform?

I saw that if we have no after and it's a /page/number and hasNextPage, we push data to allPosts and then get back to it to show page 900.

I am new to wp graphql so I'm not sure. If we have no after, there is now way for us to go straight to a specific page/offset, right?
Are there any plans for that?

I really like your work, there are a lot of benefits over rest.
Thanks for the good work and thanks for your time :)

What about if we have a lot of posts, let's say more that 10k with 10 per page and the user arrives from google on one of our last, blog/page/900. How this will perform?

So, in this particular case, all the data is fetched up front and built into a static Gatsby site, so if the user visited /page/900 they would be looking at a static list of content. It would not be fetching from WordPress + WPGraphQL directly when the user is visiting the page, so performance for users would be great.

The downside is the build time, where if you wanted to add content to your site, it would need to re-build the entire site, which takes longer the more content there is, but the upside is the performance gains for the user.

We (folks at Gatsby) are working on ways for sites to be built incrementally, so potentially sooner than later, the site rebuilds might be minimal.

I saw that if we have no after and it's a /page/number and hasNextPage, we push data to allPosts and then get back to it to show page 900.

I am new to wp graphql so I'm not sure. If we have no after, there is now way for us to go straight to a specific page/offset, right?
Are there any plans for that?

I'm not 100% sure I follow here.

What the code here is doing is fetching all posts and storing them in the allPosts array

Then, we iterate over that array and create the paginated lists here: https://github.com/wp-graphql/gatsby-wpgraphql-blog-example/blob/master/gatsby/createPosts.js#L43-L52

This allows us to see 10 posts on each page, for example:

https://gatsby-wpgraphql-blog-example.netlify.com/page/1
https://gatsby-wpgraphql-blog-example.netlify.com/page/2
https://gatsby-wpgraphql-blog-example.netlify.com/page/3