@wpnuxt/core 2.0.0-alpha.6 → 2.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json
CHANGED
|
@@ -3,7 +3,6 @@ import { computed, ref, watch as vueWatch, useAsyncGraphqlQuery } from "#imports
|
|
|
3
3
|
export const useWPContent = (queryName, nodes, fixImagePaths, params, options) => {
|
|
4
4
|
const {
|
|
5
5
|
clientCache,
|
|
6
|
-
cacheKey,
|
|
7
6
|
getCachedData: userGetCachedData,
|
|
8
7
|
retry: retryOption,
|
|
9
8
|
retryDelay: retryDelayOption,
|
|
@@ -15,11 +14,6 @@ export const useWPContent = (queryName, nodes, fixImagePaths, params, options) =
|
|
|
15
14
|
const retryCount = ref(0);
|
|
16
15
|
const isRetrying = ref(false);
|
|
17
16
|
const timeoutMs = timeoutOption ?? 0;
|
|
18
|
-
const graphqlCaching = clientCache === false ? { client: false } : restOptions.graphqlCaching ?? { client: true };
|
|
19
|
-
const paramsKey = params ? JSON.stringify(params) : "{}";
|
|
20
|
-
const baseKey = `wpnuxt-${String(queryName)}-${paramsKey}`;
|
|
21
|
-
const finalKey = cacheKey ? `${baseKey}-${cacheKey}` : baseKey;
|
|
22
|
-
const effectiveGetCachedData = userGetCachedData ?? (clientCache === false ? () => void 0 : void 0);
|
|
23
17
|
let abortController;
|
|
24
18
|
let timeoutId;
|
|
25
19
|
if (timeoutMs > 0) {
|
|
@@ -31,14 +25,21 @@ export const useWPContent = (queryName, nodes, fixImagePaths, params, options) =
|
|
|
31
25
|
}
|
|
32
26
|
}, timeoutMs);
|
|
33
27
|
}
|
|
34
|
-
const
|
|
28
|
+
const ssgGetCachedData = userGetCachedData ?? (clientCache === false ? () => void 0 : (key, app, ctx) => {
|
|
29
|
+
if (app.isHydrating) {
|
|
30
|
+
return app.payload.data[key];
|
|
31
|
+
}
|
|
32
|
+
if (ctx.cause === "refresh:manual" || ctx.cause === "refresh:hook") {
|
|
33
|
+
return void 0;
|
|
34
|
+
}
|
|
35
|
+
return app.static?.data?.[key] ?? app.payload.data[key] ?? app.$graphqlCache?.get(key);
|
|
36
|
+
});
|
|
37
|
+
const asyncDataOptions = {
|
|
35
38
|
...restOptions,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// Otherwise let nuxt-graphql-middleware handle it with $graphqlCache
|
|
41
|
-
...effectiveGetCachedData && { getCachedData: effectiveGetCachedData },
|
|
39
|
+
// Our getCachedData that properly checks static.data for SSG
|
|
40
|
+
getCachedData: ssgGetCachedData,
|
|
41
|
+
// Enable graphql caching so the LRU cache is populated for subsequent navigations
|
|
42
|
+
graphqlCaching: { client: clientCache !== false },
|
|
42
43
|
// Pass abort signal for timeout support
|
|
43
44
|
...abortController && {
|
|
44
45
|
fetchOptions: {
|
|
@@ -48,9 +49,9 @@ export const useWPContent = (queryName, nodes, fixImagePaths, params, options) =
|
|
|
48
49
|
}
|
|
49
50
|
};
|
|
50
51
|
const { data, pending, refresh, execute, clear, error, status } = useAsyncGraphqlQuery(
|
|
51
|
-
queryName,
|
|
52
|
+
String(queryName),
|
|
52
53
|
params ?? {},
|
|
53
|
-
|
|
54
|
+
asyncDataOptions
|
|
54
55
|
);
|
|
55
56
|
const transformError = ref(null);
|
|
56
57
|
if (timeoutId !== void 0) {
|