cache meatobject requests

Signed-off-by: Chloe <pinkcloudvnn@gmail.com>
This commit is contained in:
Chloe 2024-07-09 12:04:28 +07:00
parent 5ef8470526
commit b8f6bc24d2
No known key found for this signature in database
GPG Key ID: CFD53CE570D42DF5

View File

@ -205,12 +205,14 @@ async function shopifyAdminFetch<T>({
headers, headers,
query, query,
variables, variables,
tags tags,
cache = 'no-store'
}: { }: {
headers?: HeadersInit; headers?: HeadersInit;
query: string; query: string;
variables?: ExtractVariables<T>; variables?: ExtractVariables<T>;
tags?: string[]; tags?: string[];
cache?: RequestCache;
}): Promise<{ status: number; body: T } | never> { }): Promise<{ status: number; body: T } | never> {
try { try {
const result = await fetch(adminEndpoint, { const result = await fetch(adminEndpoint, {
@ -225,7 +227,7 @@ async function shopifyAdminFetch<T>({
...(variables && { variables }) ...(variables && { variables })
}), }),
...(tags && { next: { tags } }), ...(tags && { next: { tags } }),
cache: 'no-store' cache
}); });
const body = await result.json(); const body = await result.json();
@ -939,7 +941,8 @@ export async function getMetaobjectReferences(
data: { metaobject: ShopifyMetaobject }; data: { metaobject: ShopifyMetaobject };
}>({ }>({
query: getMetaobjectReferencesQuery, query: getMetaobjectReferencesQuery,
variables: { id, after } variables: { id, after },
cache: 'force-cache'
}); });
const metaobject = res.body.data.metaobject; const metaobject = res.body.data.metaobject;