@lewebsimple/nuxt-graphql 0.1.12 → 0.1.14
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.d.mts +2 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +14 -6
- package/package.json +2 -2
package/dist/module.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
import { GraphQLCacheConfig } from '../dist/runtime/utils/graphql-cache.js';
|
|
3
|
+
import { CodegenConfig } from '@graphql-codegen/cli';
|
|
3
4
|
|
|
4
5
|
interface ModuleOptions {
|
|
5
6
|
endpoint?: string;
|
|
@@ -12,6 +13,7 @@ interface ModuleOptions {
|
|
|
12
13
|
input: string;
|
|
13
14
|
output: string;
|
|
14
15
|
}>;
|
|
16
|
+
generates?: CodegenConfig["generates"];
|
|
15
17
|
};
|
|
16
18
|
}
|
|
17
19
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -175,7 +175,7 @@ function formatDefinitions(defs) {
|
|
|
175
175
|
return defs.map((def) => `${colorOf(def)}${def.name}${reset}`).join(`${dim} / ${reset}`);
|
|
176
176
|
}
|
|
177
177
|
async function runCodegen(options) {
|
|
178
|
-
const {
|
|
178
|
+
const { schema, documents, operationsFile, schemasFile, scalars, generates: customGenerates } = options;
|
|
179
179
|
if (documents.length === 0) {
|
|
180
180
|
logger.warn("No GraphQL documents found");
|
|
181
181
|
return;
|
|
@@ -202,6 +202,8 @@ async function runCodegen(options) {
|
|
|
202
202
|
try {
|
|
203
203
|
const generates = {
|
|
204
204
|
[operationsFile]: {
|
|
205
|
+
schema,
|
|
206
|
+
documents,
|
|
205
207
|
plugins: ["typescript", "typescript-operations", "typed-document-node"],
|
|
206
208
|
config: {
|
|
207
209
|
useTypeImports: true,
|
|
@@ -217,6 +219,8 @@ async function runCodegen(options) {
|
|
|
217
219
|
};
|
|
218
220
|
if (schemasFile) {
|
|
219
221
|
generates[schemasFile] = {
|
|
222
|
+
schema,
|
|
223
|
+
documents,
|
|
220
224
|
plugins: ["typescript-validation-schema"],
|
|
221
225
|
config: {
|
|
222
226
|
schema: "zodv4",
|
|
@@ -232,8 +236,11 @@ async function runCodegen(options) {
|
|
|
232
236
|
scalarSchemas: zodScalars
|
|
233
237
|
}
|
|
234
238
|
};
|
|
239
|
+
if (customGenerates) {
|
|
240
|
+
Object.assign(generates, customGenerates);
|
|
241
|
+
}
|
|
235
242
|
}
|
|
236
|
-
await generate({
|
|
243
|
+
await generate({ generates, silent: true, errorsOnly: true }, true);
|
|
237
244
|
logger.success(`Generated types for ${documents.length} document(s)`);
|
|
238
245
|
} catch (error) {
|
|
239
246
|
logger.error("GraphQL codegen failed:", error instanceof Error ? error.message : error);
|
|
@@ -305,7 +312,7 @@ const module$1 = defineNuxtModule({
|
|
|
305
312
|
}
|
|
306
313
|
const schemaFile = join(rootDir, schemaOutput);
|
|
307
314
|
const generate = async () => {
|
|
308
|
-
const [
|
|
315
|
+
const [schema, documents] = await Promise.all([
|
|
309
316
|
loadGraphQLSchema(schemaPath),
|
|
310
317
|
findMultipleFiles(layerRootDirs, codegenPattern)
|
|
311
318
|
]);
|
|
@@ -317,13 +324,14 @@ const module$1 = defineNuxtModule({
|
|
|
317
324
|
logger.info(`${cyan}${relativePath}${reset} [${formatDefinitions(defs)}]`);
|
|
318
325
|
}
|
|
319
326
|
await runCodegen({
|
|
320
|
-
|
|
327
|
+
schema,
|
|
321
328
|
documents,
|
|
322
329
|
operationsFile,
|
|
323
330
|
schemasFile,
|
|
324
|
-
scalars: options.codegen?.scalars
|
|
331
|
+
scalars: options.codegen?.scalars,
|
|
332
|
+
generates: options.codegen?.generates
|
|
325
333
|
});
|
|
326
|
-
if (writeFileIfChanged(schemaFile,
|
|
334
|
+
if (writeFileIfChanged(schemaFile, schema)) {
|
|
327
335
|
logger.info(`GraphQL schema saved to ${cyan}${schemaOutput}${reset}`);
|
|
328
336
|
}
|
|
329
337
|
const graphqlrc = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lewebsimple/nuxt-graphql",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "Opinionated Nuxt module for using GraphQL",
|
|
5
5
|
"repository": "lewebsimple/nuxt-graphql",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@nuxt/eslint-config": "^1.12.1",
|
|
58
58
|
"@nuxt/module-builder": "^1.0.2",
|
|
59
59
|
"@nuxt/schema": "^4.2.2",
|
|
60
|
-
"@nuxt/test-utils": "^3.
|
|
60
|
+
"@nuxt/test-utils": "^3.22.0",
|
|
61
61
|
"@types/node": "latest",
|
|
62
62
|
"@vitest/coverage-v8": "^4.0.16",
|
|
63
63
|
"changelogen": "^0.6.2",
|