@samlittlefair Thanks for your answer and the insight,
Indeed some documents in my repository are a bit big (due to integration field being big). I will try to work on trimming them.
I’m using useGetStaticProps and useGetStaticPaths of next-slicezone so changing the pageSize change almost nothing to me.
On a side note, I realized that I was not running the latest version of next-sliceone which add document type filtering on useGetStaticPaths. It does not change my problem but at least it avoid fetching all the document when only those of a specific type are needed.
The issue here is my documents being large, and getStaticPaths wanting to fetch a lot of them (of course I could reduce the pageSize if needed).
Providing the document type in useGetStaticPaths allow me to use some of prismic feature such as graphQuery. Using graphQuery I make a request to only fetch the fields needed to build the needed next path (which should not consist of more than a few field). In my case it’s only the uid field so I end up doing a "dummy" graphQuery to retrieve only the uid field (which is not stored in the data anyway) but at least it makes it possible to not fetch all the data related to the document I want the uid for.
const graphQuery = `{
page {
uid
}
}`;
export const getStaticPaths = useGetStaticPaths({
client: Client(),
type: 'page',
getStaticPathsParams: {
fallback: process.env.NODE_ENV === 'development',
},
formatPath: ({ uid }) => ({ params: { uid } }),
lang: 'fr-fr',
params: {
graphQuery: graphQuery,
},
});
Perhaps there is a way to specify I want none of the data of the retrieved prismicDocument ?
On a side note I would like to add that next-slicezone Technical Reference - Prismic documentation is a bit missleading. In the useGetStaticPaths paragraph, the part about lang and uid being no longer parameters (but instead in apiParams). The "solution" function miss the point as both the function
export const getStaticPaths = useGetStaticPaths({
client: Client(),
type: 'page',
formatPath: ({ uid }) => ({ params: { uid } })
})
and
export const getStaticPaths = useGetStaticPaths({
client: Client(),
type: 'page',
formatPath: (prismicDocument) => {
return {
params: {
uid: prismicDocument.uid
}
}
}
});
seems equivalent to me.
Best,