nitro-graphql 0.0.6 → 0.0.8
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/ecosystem/nuxt.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _nuxt_schema7 from "@nuxt/schema";
|
|
2
2
|
|
|
3
3
|
//#region src/ecosystem/nuxt.d.ts
|
|
4
4
|
interface ModuleOptions {}
|
|
5
|
-
declare const _default:
|
|
5
|
+
declare const _default: _nuxt_schema7.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { ModuleOptions, _default as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from "./types/standard-schema.js";
|
|
2
2
|
import { CodegenClientConfig, CodegenServerConfig, GenImport, NitroGraphQLOptions } from "./types/index.js";
|
|
3
3
|
import { defineGraphQLConfig, defineMutation, defineQuery, defineResolver, defineSchema, defineSubscription, defineType } from "./utils/define.js";
|
|
4
|
-
import * as
|
|
4
|
+
import * as nitropack4 from "nitropack";
|
|
5
5
|
|
|
6
6
|
//#region src/index.d.ts
|
|
7
7
|
interface Resolvers extends Record<string, any> {}
|
|
8
8
|
interface CustomSchema extends Record<string, any> {}
|
|
9
9
|
type GraphQLFramework = 'graphql-yoga';
|
|
10
|
-
declare const _default:
|
|
10
|
+
declare const _default: nitropack4.NitroModule;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { CodegenClientConfig, CodegenServerConfig, CustomSchema, GenImport, GraphQLFramework, NitroGraphQLOptions, Resolvers, StandardSchemaV1, _default as default, defineGraphQLConfig, defineMutation, defineQuery, defineResolver, defineSchema, defineSubscription, defineType };
|
package/dist/index.js
CHANGED
|
@@ -142,6 +142,7 @@ declare module 'nitro-graphql' {
|
|
|
142
142
|
types.tsConfig.compilerOptions.paths ??= {};
|
|
143
143
|
types.tsConfig.compilerOptions.paths["#graphql/server"] = [relativeWithDot(tsconfigDir, join(typesDir, "nitro-graphql-server.d.ts"))];
|
|
144
144
|
types.tsConfig.compilerOptions.paths["#graphql/client"] = [relativeWithDot(tsconfigDir, join(typesDir, "nitro-graphql-client.d.ts"))];
|
|
145
|
+
types.tsConfig.compilerOptions.paths["#graphql/schemas"] = [relativeWithDot(tsconfigDir, join(nitro.graphql.serverDir, "schemas.ts"))];
|
|
145
146
|
types.tsConfig.include = types.tsConfig.include || [];
|
|
146
147
|
types.tsConfig.include.push(relativeWithDot(tsconfigDir, join(typesDir, "nitro-graphql-server.d.ts")), relativeWithDot(tsconfigDir, join(typesDir, "nitro-graphql-client.d.ts")), relativeWithDot(tsconfigDir, join(typesDir, "graphql.d.ts")));
|
|
147
148
|
});
|
package/dist/routes/health.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h35 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/health.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: h35.EventHandler<h35.EventHandlerRequest, Promise<{
|
|
5
5
|
status: string;
|
|
6
6
|
message: string;
|
|
7
7
|
timestamp: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { generateClientTypes, loadGraphQLDocuments } from "./client-codegen.js";
|
|
2
2
|
import { generateTypes } from "./server-codegen.js";
|
|
3
|
-
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { dirname, join, resolve } from "pathe";
|
|
5
5
|
import { buildASTSchema, buildSchema } from "graphql";
|
|
6
6
|
import { loadFilesSync } from "@graphql-tools/load-files";
|
|
@@ -12,6 +12,10 @@ import consola from "consola";
|
|
|
12
12
|
async function serverTypeGeneration(app) {
|
|
13
13
|
try {
|
|
14
14
|
const defs = app.scanDefs || [];
|
|
15
|
+
if (!defs.length) {
|
|
16
|
+
consola.info("No GraphQL definitions found for server type generation.");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
15
19
|
const loadDefs = loadFilesSync(defs);
|
|
16
20
|
const mergedDefs = mergeTypeDefs(loadDefs);
|
|
17
21
|
const schema = buildASTSchema(mergedDefs, {
|
|
@@ -35,7 +39,12 @@ async function clientTypeGeneration(app, path) {
|
|
|
35
39
|
const root = app.graphql.watchDirs.find((dir) => path.startsWith(dir)) || path;
|
|
36
40
|
if (!root) return;
|
|
37
41
|
const docs = await loadGraphQLDocuments(root);
|
|
38
|
-
const
|
|
42
|
+
const schemaFilePath = join(app.graphql.buildDir, "schema.graphql");
|
|
43
|
+
if (!existsSync(schemaFilePath)) {
|
|
44
|
+
consola.info("Schema file not ready yet for client type generation. Server types need to be generated first.");
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const graphqlString = readFileSync(schemaFilePath, "utf-8");
|
|
39
48
|
const schema = buildSchema(graphqlString);
|
|
40
49
|
const types = await generateClientTypes(schema, docs);
|
|
41
50
|
if (types === false) return;
|