Skip to content

Commit

Permalink
fix: parentId query variable
Browse files Browse the repository at this point in the history
  • Loading branch information
dlhck committed Jan 21, 2025
1 parent e4774e4 commit 7e5cb55
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/vendure/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import {
GetCollectionProductsQuery,
GetCollectionProductsQueryVariables,
GetCollectionQuery,
GetCollectionQueryVariables, GetCollectionsQuery, GetCollectionsQueryVariables,
GetCollectionQueryVariables,
GetCollectionsQuery,
GetCollectionsQueryVariables,
GetFacetsQuery,
GetFacetsQueryVariables,
GetProductQuery,
Expand Down Expand Up @@ -261,11 +263,11 @@ export async function getCollections({
tags: [TAGS.collections],
variables: {
topLevelOnly,
...(parentId && { filter: { parent: { eq: parentId } } })
...(parentId && { filter: { parentId: { eq: parentId } } })
}
});

return res.body.collections.items
return res.body.collections.items;
}

export async function getFacets() {
Expand Down Expand Up @@ -328,16 +330,15 @@ export async function getPage(slug: string) {

// This is called from `app/api/revalidate.ts` so providers can control revalidation logic.
export async function revalidate(req: NextRequest): Promise<NextResponse> {
// We always need to respond with a 200 status code to Shopify,
// otherwise it will continue to retry the request.
const collectionWebhooks = ['collections/create', 'collections/delete', 'collections/update'];
const productWebhooks = ['products/create', 'products/delete', 'products/update'];
const topic = (await headers()).get('x-shopify-topic') || 'unknown';
// TODO: Implement webhooks in Vendure repo
const topic = 'unknown';
const secret = req.nextUrl.searchParams.get('secret');
const isCollectionUpdate = collectionWebhooks.includes(topic);
const isProductUpdate = productWebhooks.includes(topic);

if (!secret || secret !== process.env.SHOPIFY_REVALIDATION_SECRET) {
if (!secret || secret !== process.env.VENDURE_REVALIDATION_SECRET) {
console.error('Invalid revalidation secret.');
return NextResponse.json({ status: 401 });
}
Expand Down

0 comments on commit 7e5cb55

Please sign in to comment.