@lewebsimple/nuxt-graphql 0.5.9 → 0.5.10
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/README.md +3 -4
- package/dist/module.json +1 -1
- package/dist/module.mjs +10 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -163,9 +163,8 @@ Write operations in `.gql` files; operation names become registry keys like `use
|
|
|
163
163
|
|
|
164
164
|
By default, the module scans `**/*.gql` and generates:
|
|
165
165
|
|
|
166
|
-
- Typed documents and types in virtual modules under the `#graphql/operations` alias (internal)
|
|
166
|
+
- Typed documents and operations / fragments types in virtual modules under the `#graphql/operations` alias (internal)
|
|
167
167
|
- Operation registry in virtual modules under the `#graphql/registry` alias (internal)
|
|
168
|
-
- Fragment types in virtual modules under the `#graphql/fragments` alias
|
|
169
168
|
|
|
170
169
|
Example document files:
|
|
171
170
|
|
|
@@ -198,7 +197,7 @@ That's it! You can now use Nuxt GraphQL in your Nuxt app ✨
|
|
|
198
197
|
Fragments are fully supported and are the recommended way to share selection sets across operations.
|
|
199
198
|
|
|
200
199
|
- Fragment names must be unique across all `.gql` files (duplicates throw during generation).
|
|
201
|
-
- Fragment types are re-exported from `#graphql/
|
|
200
|
+
- Fragment types are re-exported from `#graphql/operations`.
|
|
202
201
|
- Fragments are not executable by themselves and are not part of the registry.
|
|
203
202
|
|
|
204
203
|
Example with a fragment:
|
|
@@ -222,7 +221,7 @@ query SwapiFilms {
|
|
|
222
221
|
From TypeScript, you can also use fragment types explicitly when needed:
|
|
223
222
|
|
|
224
223
|
```ts
|
|
225
|
-
import type { TheFilmFragment } from "#graphql/
|
|
224
|
+
import type { TheFilmFragment } from "#graphql/operations";
|
|
226
225
|
```
|
|
227
226
|
|
|
228
227
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -97,7 +97,7 @@ async function renderOperationsTemplate({ schema, documents }) {
|
|
|
97
97
|
const module = docs.map(({ name, object }) => `export const ${name} = ${object};`).join("\n");
|
|
98
98
|
const types = `${content.replace(/export const \w+ = [\s\S]*?;\n?/g, "")}
|
|
99
99
|
declare module "#graphql/operations" {
|
|
100
|
-
${docs.map(({ name, type }) => `export
|
|
100
|
+
${docs.map(({ name, type }) => `export const ${name}: ${type};`).join("\n ")}
|
|
101
101
|
}`.trim();
|
|
102
102
|
return { module, types };
|
|
103
103
|
}
|
|
@@ -305,7 +305,6 @@ export {};
|
|
|
305
305
|
function renderSharedTypesTemplate() {
|
|
306
306
|
return `
|
|
307
307
|
import type { DocumentNode } from "graphql";
|
|
308
|
-
import type { CacheConfig } from "nuxt-graphql/runtime/shared/lib/cache-config";
|
|
309
308
|
|
|
310
309
|
declare global {
|
|
311
310
|
type GraphQLCacheConfig = {
|
|
@@ -326,7 +325,6 @@ declare module "nuxt/schema" {
|
|
|
326
325
|
}
|
|
327
326
|
|
|
328
327
|
export { };
|
|
329
|
-
|
|
330
328
|
`.trim();
|
|
331
329
|
}
|
|
332
330
|
|
|
@@ -360,7 +358,7 @@ const module$1 = defineNuxtModule({
|
|
|
360
358
|
return relativePath;
|
|
361
359
|
}
|
|
362
360
|
nuxt.options.alias ||= {};
|
|
363
|
-
nuxt.options.alias["#graphql"]
|
|
361
|
+
nuxt.options.alias["#graphql"] = resolveBuild("graphql");
|
|
364
362
|
const buildCache = /* @__PURE__ */ new Map();
|
|
365
363
|
function cachedLoader(baseKey, loader) {
|
|
366
364
|
return async (...args) => {
|
|
@@ -424,7 +422,9 @@ const module$1 = defineNuxtModule({
|
|
|
424
422
|
"!**/dist/**",
|
|
425
423
|
"!**/node_modules/**"
|
|
426
424
|
], { loaders: [new GraphQLFileLoader()] });
|
|
427
|
-
} catch {
|
|
425
|
+
} catch (error) {
|
|
426
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
427
|
+
logger.warn(`Failed to load documents: ${message}`);
|
|
428
428
|
return [];
|
|
429
429
|
}
|
|
430
430
|
});
|
|
@@ -470,8 +470,11 @@ const module$1 = defineNuxtModule({
|
|
|
470
470
|
nuxt.hook("builder:watch", async (_event, changedPath) => {
|
|
471
471
|
if (changedPath.endsWith(".gql")) {
|
|
472
472
|
logger.info(`Documents change detected: ${cyan}${getRelativePath(changedPath)}${reset}`);
|
|
473
|
-
buildCache.
|
|
474
|
-
|
|
473
|
+
for (const key of buildCache.keys()) {
|
|
474
|
+
if (key.startsWith("documents:") || key.startsWith("operations:") || key.startsWith("registry:")) {
|
|
475
|
+
buildCache.delete(key);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
475
478
|
}
|
|
476
479
|
});
|
|
477
480
|
}
|