Fetch all documents in getStaticPaths with GraphQL

Prismic documentation, albeit quite hidden, says the following (Source):

The Prismic GraphQL API returns a maximum of 20 documents per request. There is no way to increase this number, so this page explains how you can retrieve more than this initial 20 documents.

I truly understand this limitation, but it makes it very cumber-stone for Next.js and its getStaticPaths where one normally only needs to query the UID for each document. In this use-case the Prismic GraphQL API should not be under a heavy load at all even when returning hundreds of documents.

Are there any chances for Prismic GraphQL API to enable something in terms of queryAllUIDs to greatly simplify this scenario?

Alternatively, would anyone have a reusable solution for the said problem? Creating a function to bypass this limitation seems to require tons of unique extra props for each custom type compared to simply fetching all the data up to the limit of 20, and typically this behaviour is required on every route of every website.

1 Like

Hi Jere,

I have checked with our dev team and the current limit is set to 20 documents, I will tag this thread as a feature request where I find it really useful to implement someway return more documents when fetching only one level.

FYI@activations-team

Please let us know if you have any other questions.

1 Like

This is being tracked as an open feature request.

If you have another use-case for this feature, you can 'Flag' this topic to reopen. Please use the :heart: button to show your support for the feature and check out our Feature Request Guidelines.

Hi @hi1,

Using Prismic's client v6, you can now perform getAllByType queries to create paths with getStaticPaths.

We explain how to do that in the define paths article:

Let me know if you have any questions about this.

Thanks.