In my Next.js project connected to Apollo, I have around 50 static URLs fetching data using getStaticProps(). The performance is great, and I enjoy how the pages load. However, a problem arises when Vercel builds the static versions of these pages during deployment - I tend to hit the rate limits for the API after about 40 pages are built. Since I cannot control these rate limits, I'm looking for a way to throttle my data calls within each getStaticProps to stagger them at build time. My current getStaticProps function on each page looks something like this:
export async function getStaticProps() {
const apolloClient = initializeApollo()
await apolloClient.query({
query: XXXXXXX,
variables: {handle: "XXXXXXX"}
})
return {
props: {
initialApolloState: apolloClient.cache.extract(),
},
revalidate: 1,
}
}
Everything was running smoothly until I had more pages and started hitting the rate limit issue.