@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
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.0.0"
6
6
  },
7
- "version": "2.0.0-alpha.5",
7
+ "version": "2.0.0-alpha.6",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
@@ -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 mergedOptions = {
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
- graphqlCaching,
37
- // Explicit key ensures consistent cache lookups
38
- key: finalKey,
39
- // Only set getCachedData if user provided one or wants to disable caching
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
- mergedOptions
54
+ asyncDataOptions
54
55
  );
55
56
  const transformError = ref(null);
56
57
  if (timeoutId !== void 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wpnuxt/core",
3
- "version": "2.0.0-alpha.6",
3
+ "version": "2.0.0-alpha.7",
4
4
  "description": "Nuxt module for WordPress integration via GraphQL (WPGraphQL)",
5
5
  "keywords": [
6
6
  "nuxt",