From 58f25ad8c9ab5c461f58beecc41ff63a5d30af83 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 1 Jun 2021 09:26:32 +0200 Subject: [PATCH] parallel requests --- pages/product/[slug].tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pages/product/[slug].tsx b/pages/product/[slug].tsx index ac55dc4be..b8e4c12fc 100644 --- a/pages/product/[slug].tsx +++ b/pages/product/[slug].tsx @@ -19,13 +19,16 @@ export async function getStaticProps({ preview, }: GetStaticPropsContext<{ slug: string }>) { const config = getConfig({ locale }) - const { pages } = await getAllPages({ config, preview }) - const { product } = await getProduct({ + const pagesPromise = getAllPages({ config, preview }) + const productPromise = getProduct({ variables: { slug: params!.slug }, config, preview, }) - const { categories } = await getSiteInfo({ config, preview }) + const siteInfoPromise = getSiteInfo({ config, preview }) + const { pages } = await pagesPromise + const { product } = await productPromise + const { categories } = await siteInfoPromise if (!product) { throw new Error(`Product with slug '${params!.slug}' not found`)