nitro-graphql 1.4.4 → 2.0.0-beta.1
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.js +1 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -7
- package/dist/routes/apollo-server.d.ts +2 -2
- package/dist/routes/apollo-server.js +8 -13
- package/dist/routes/graphql-yoga.d.ts +2 -2
- package/dist/routes/graphql-yoga.js +14 -21
- package/dist/routes/health.d.ts +2 -6
- package/dist/routes/health.js +6 -4
- package/dist/types/index.d.ts +2 -2
- package/dist/utils/client-codegen.js +17 -26
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -3
- package/dist/utils/server-codegen.js +2 -3
- package/dist/utils/type-generation.d.ts +1 -1
- package/dist/utils/type-generation.js +3 -5
- package/package.json +5 -5
package/dist/ecosystem/nuxt.js
CHANGED
|
@@ -43,8 +43,7 @@ var nuxt_default = defineNuxtModule({
|
|
|
43
43
|
nitroConfig.graphql.layerDirectories = layerDirectories;
|
|
44
44
|
nitroConfig.graphql.layerServerDirs = layerServerDirs;
|
|
45
45
|
nitroConfig.graphql.layerAppDirs = layerAppDirs;
|
|
46
|
-
|
|
47
|
-
if (!existsSync(appGraphqlDir)) {
|
|
46
|
+
if (!existsSync(resolve(nuxt.options.rootDir, "app/graphql"))) {
|
|
48
47
|
const defaultDir = join(clientDir, "default");
|
|
49
48
|
if (!existsSync(defaultDir)) mkdirSync(defaultDir, { recursive: true });
|
|
50
49
|
const sampleQueryFile = join(defaultDir, "queries.graphql");
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from "./types/standard-schema.js";
|
|
2
2
|
import { CodegenClientConfig, CodegenServerConfig, ExternalGraphQLService, FederationConfig, GenImport, GenericSdkConfig, NitroGraphQLOptions } from "./types/index.js";
|
|
3
|
-
import * as
|
|
3
|
+
import * as nitro_types0 from "nitro/types";
|
|
4
4
|
|
|
5
5
|
//#region src/index.d.ts
|
|
6
|
-
declare const _default:
|
|
6
|
+
declare const _default: nitro_types0.NitroModule;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { CodegenClientConfig, CodegenServerConfig, ExternalGraphQLService, FederationConfig, GenImport, GenericSdkConfig, NitroGraphQLOptions, StandardSchemaV1, _default as default };
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,6 @@ import { fileURLToPath } from "node:url";
|
|
|
7
7
|
import { watch } from "chokidar";
|
|
8
8
|
import consola from "consola";
|
|
9
9
|
import defu from "defu";
|
|
10
|
-
import { defineNitroModule } from "nitropack/kit";
|
|
11
10
|
import { dirname, join, relative, resolve } from "pathe";
|
|
12
11
|
|
|
13
12
|
//#region src/index.ts
|
|
@@ -96,8 +95,7 @@ var src_default = defineNitroModule({
|
|
|
96
95
|
nitro.hooks.hook("close", () => {
|
|
97
96
|
watcher.close();
|
|
98
97
|
});
|
|
99
|
-
const
|
|
100
|
-
const tsconfigDir = dirname(tsConfigPath);
|
|
98
|
+
const tsconfigDir = dirname(resolve(nitro.options.buildDir, nitro.options.typescript.tsconfigPath));
|
|
101
99
|
const typesDir = resolve(nitro.options.buildDir, "types");
|
|
102
100
|
nitro.scanSchemas = await scanSchemas(nitro);
|
|
103
101
|
nitro.scanDocuments = await scanDocs(nitro);
|
|
@@ -122,9 +120,9 @@ var src_default = defineNitroModule({
|
|
|
122
120
|
});
|
|
123
121
|
const runtime = fileURLToPath(new URL("routes", import.meta.url));
|
|
124
122
|
const methods = [
|
|
125
|
-
"
|
|
126
|
-
"
|
|
127
|
-
"
|
|
123
|
+
"GET",
|
|
124
|
+
"POST",
|
|
125
|
+
"OPTIONS"
|
|
128
126
|
];
|
|
129
127
|
if (nitro.options.graphql?.framework === "graphql-yoga") for (const method of methods) nitro.options.handlers.push({
|
|
130
128
|
route: nitro.options.runtimeConfig.graphql?.endpoint?.graphql || "/api/graphql",
|
|
@@ -139,7 +137,7 @@ var src_default = defineNitroModule({
|
|
|
139
137
|
nitro.options.handlers.push({
|
|
140
138
|
route: nitro.options.runtimeConfig.graphql?.endpoint?.healthCheck || "/api/graphql/health",
|
|
141
139
|
handler: join(runtime, "health"),
|
|
142
|
-
method: "
|
|
140
|
+
method: "GET"
|
|
143
141
|
});
|
|
144
142
|
if (nitro.options.imports) {
|
|
145
143
|
nitro.options.imports.presets ??= [];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h33 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/apollo-server.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: h33.EventHandler<h33.EventHandlerRequest, unknown>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
|
@@ -26,8 +26,7 @@ async function loadFederationSupport() {
|
|
|
26
26
|
}
|
|
27
27
|
async function createMergedSchema() {
|
|
28
28
|
try {
|
|
29
|
-
const
|
|
30
|
-
const typeDefs = mergeTypeDefs([mergedSchemas], {
|
|
29
|
+
const typeDefs = mergeTypeDefs([schemas.map((schema$1) => schema$1.def).join("\n\n")], {
|
|
31
30
|
throwOnConflict: true,
|
|
32
31
|
commentDescriptions: true,
|
|
33
32
|
sort: true
|
|
@@ -37,13 +36,11 @@ async function createMergedSchema() {
|
|
|
37
36
|
let schema;
|
|
38
37
|
if (federationEnabled) {
|
|
39
38
|
const buildSubgraph = await loadFederationSupport();
|
|
40
|
-
if (buildSubgraph) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
-
} else {
|
|
39
|
+
if (buildSubgraph) schema = buildSubgraph({
|
|
40
|
+
typeDefs: typeof typeDefs === "string" ? parse(typeDefs) : typeDefs,
|
|
41
|
+
resolvers: mergedResolvers
|
|
42
|
+
});
|
|
43
|
+
else {
|
|
47
44
|
console.warn("Federation enabled but @apollo/subgraph not available, falling back to regular schema");
|
|
48
45
|
schema = makeExecutableSchema({
|
|
49
46
|
typeDefs,
|
|
@@ -67,9 +64,8 @@ let apolloServer = null;
|
|
|
67
64
|
let serverStarted = false;
|
|
68
65
|
async function createApolloServer() {
|
|
69
66
|
if (!apolloServer) {
|
|
70
|
-
const schema = await createMergedSchema();
|
|
71
67
|
apolloServer = new ApolloServer(defu({
|
|
72
|
-
schema,
|
|
68
|
+
schema: await createMergedSchema(),
|
|
73
69
|
introspection: true,
|
|
74
70
|
plugins: [ApolloServerPluginLandingPageLocalDefault({ embed: true })]
|
|
75
71
|
}, importedConfig));
|
|
@@ -83,8 +79,7 @@ async function createApolloServer() {
|
|
|
83
79
|
let serverPromise = null;
|
|
84
80
|
var apollo_server_default = defineEventHandler(async (event) => {
|
|
85
81
|
if (!serverPromise) serverPromise = createApolloServer();
|
|
86
|
-
|
|
87
|
-
return startServerAndCreateH3Handler(server, {
|
|
82
|
+
return startServerAndCreateH3Handler(await serverPromise, {
|
|
88
83
|
context: async () => ({ event }),
|
|
89
84
|
serverAlreadyStarted: true
|
|
90
85
|
})(event);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h31 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/graphql-yoga.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: h31.EventHandler<h31.EventHandlerRequest, unknown>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
|
@@ -8,7 +8,7 @@ import { directives } from "#nitro-internal-virtual/server-directives";
|
|
|
8
8
|
import { resolvers } from "#nitro-internal-virtual/server-resolvers";
|
|
9
9
|
import { schemas } from "#nitro-internal-virtual/server-schemas";
|
|
10
10
|
import { makeExecutableSchema } from "@graphql-tools/schema";
|
|
11
|
-
import { defineEventHandler
|
|
11
|
+
import { defineEventHandler } from "h3";
|
|
12
12
|
import { createYoga } from "graphql-yoga";
|
|
13
13
|
|
|
14
14
|
//#region src/routes/graphql-yoga.ts
|
|
@@ -41,8 +41,7 @@ new window.EmbeddedSandbox({
|
|
|
41
41
|
</html>`;
|
|
42
42
|
async function createMergedSchema() {
|
|
43
43
|
try {
|
|
44
|
-
const
|
|
45
|
-
const typeDefs = mergeTypeDefs([mergedSchemas], {
|
|
44
|
+
const typeDefs = mergeTypeDefs([schemas.map((schema$1) => schema$1.def).join("\n\n")], {
|
|
46
45
|
throwOnConflict: true,
|
|
47
46
|
commentDescriptions: true,
|
|
48
47
|
sort: true
|
|
@@ -52,13 +51,11 @@ async function createMergedSchema() {
|
|
|
52
51
|
let schema;
|
|
53
52
|
if (federationEnabled) {
|
|
54
53
|
const buildSubgraph = await loadFederationSupport();
|
|
55
|
-
if (buildSubgraph) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
});
|
|
61
|
-
} else {
|
|
54
|
+
if (buildSubgraph) schema = buildSubgraph({
|
|
55
|
+
typeDefs: typeof typeDefs === "string" ? parse(typeDefs) : typeDefs,
|
|
56
|
+
resolvers: mergedResolvers
|
|
57
|
+
});
|
|
58
|
+
else {
|
|
62
59
|
console.warn("Federation enabled but @apollo/subgraph not available, falling back to regular schema");
|
|
63
60
|
schema = makeExecutableSchema({
|
|
64
61
|
typeDefs,
|
|
@@ -80,17 +77,13 @@ async function createMergedSchema() {
|
|
|
80
77
|
}
|
|
81
78
|
let yoga;
|
|
82
79
|
var graphql_yoga_default = defineEventHandler(async (event) => {
|
|
83
|
-
if (!yoga) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}, importedConfig));
|
|
91
|
-
}
|
|
92
|
-
const request = toWebRequest(event);
|
|
93
|
-
const response = await yoga.handleRequest(request, event);
|
|
80
|
+
if (!yoga) yoga = createYoga(defu({
|
|
81
|
+
schema: await createMergedSchema(),
|
|
82
|
+
graphqlEndpoint: "/api/graphql",
|
|
83
|
+
landingPage: false,
|
|
84
|
+
renderGraphiQL: () => apolloSandboxHtml
|
|
85
|
+
}, importedConfig));
|
|
86
|
+
const response = await yoga.handleRequest(event.req, event);
|
|
94
87
|
return new Response(response.body, response);
|
|
95
88
|
});
|
|
96
89
|
|
package/dist/routes/health.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h30 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/health.d.ts
|
|
4
|
-
declare const _default:
|
|
5
|
-
status: string;
|
|
6
|
-
message: string;
|
|
7
|
-
timestamp: string;
|
|
8
|
-
}>>;
|
|
4
|
+
declare const _default: h30.EventHandler<h30.EventHandlerRequest, unknown>;
|
|
9
5
|
//#endregion
|
|
10
6
|
export { _default as default };
|
package/dist/routes/health.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { defineEventHandler
|
|
2
|
-
import { useRuntimeConfig } from "
|
|
1
|
+
import { defineEventHandler } from "h3";
|
|
2
|
+
import { useRuntimeConfig } from "nitro/runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/routes/health.ts
|
|
5
5
|
var health_default = defineEventHandler(async (event) => {
|
|
6
6
|
const runtime = useRuntimeConfig();
|
|
7
7
|
if (!runtime.graphql || !runtime.graphql.endpoint?.graphql) {
|
|
8
|
-
|
|
8
|
+
event.res.status = 404;
|
|
9
|
+
event.res.statusText = "Not Found";
|
|
9
10
|
return {
|
|
10
11
|
status: "error",
|
|
11
12
|
message: "GraphQL health check endpoint is not configured",
|
|
@@ -31,7 +32,8 @@ var health_default = defineEventHandler(async (event) => {
|
|
|
31
32
|
};
|
|
32
33
|
throw new Error("Invalid response from GraphQL server");
|
|
33
34
|
} catch (error) {
|
|
34
|
-
|
|
35
|
+
event.res.status = 503;
|
|
36
|
+
event.res.statusText = "Service Unavailable";
|
|
35
37
|
return {
|
|
36
38
|
status: "unhealthy",
|
|
37
39
|
message: error instanceof Error ? error.message : "GraphQL server is not responding",
|
package/dist/types/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ interface GenImport {
|
|
|
27
27
|
imports: IESMImport[];
|
|
28
28
|
options?: ESMCodeGenOptions;
|
|
29
29
|
}
|
|
30
|
-
declare module '
|
|
30
|
+
declare module 'nitro/types' {
|
|
31
31
|
interface Nitro {
|
|
32
32
|
scanSchemas: string[];
|
|
33
33
|
scanDocuments: string[];
|
|
@@ -46,7 +46,7 @@ declare module 'nitropack/types' {
|
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
declare module '
|
|
49
|
+
declare module 'nitro/types' {
|
|
50
50
|
interface NitroOptions {
|
|
51
51
|
graphql?: NitroGraphQLOptions;
|
|
52
52
|
}
|
|
@@ -101,15 +101,13 @@ async function downloadAndSaveSchema(service, buildDir) {
|
|
|
101
101
|
if (downloadMode === "always") {
|
|
102
102
|
shouldDownload = true;
|
|
103
103
|
if (fileExists && hasUrlSchemas) try {
|
|
104
|
-
const
|
|
104
|
+
const remoteSchemaString = printSchemaWithDirectives(loadSchemaSync(schemas.filter(isUrl), {
|
|
105
105
|
loaders: [new UrlLoader()],
|
|
106
106
|
...Object.keys(headers).length > 0 && { headers }
|
|
107
|
-
});
|
|
108
|
-
const remoteSchemaString = printSchemaWithDirectives(remoteSchema);
|
|
107
|
+
}));
|
|
109
108
|
const remoteHash = createHash("md5").update(remoteSchemaString).digest("hex");
|
|
110
109
|
const localSchemaString = readFileSync(schemaFilePath, "utf-8");
|
|
111
|
-
|
|
112
|
-
if (remoteHash === localHash) {
|
|
110
|
+
if (remoteHash === createHash("md5").update(localSchemaString).digest("hex")) {
|
|
113
111
|
shouldDownload = false;
|
|
114
112
|
consola$1.info(`[graphql:${service.name}] Schema is up-to-date, using cached version`);
|
|
115
113
|
}
|
|
@@ -134,24 +132,21 @@ async function downloadAndSaveSchema(service, buildDir) {
|
|
|
134
132
|
} else if (downloadMode === true || downloadMode === "once") shouldDownload = !fileExists;
|
|
135
133
|
if (shouldDownload) {
|
|
136
134
|
if (hasUrlSchemas && hasLocalSchemas) {
|
|
137
|
-
const
|
|
135
|
+
const schemaString = printSchemaWithDirectives(loadSchemaSync(schemas, {
|
|
138
136
|
loaders: [new GraphQLFileLoader(), new UrlLoader()],
|
|
139
137
|
...Object.keys(headers).length > 0 && { headers }
|
|
140
|
-
});
|
|
141
|
-
const schemaString = printSchemaWithDirectives(schema);
|
|
138
|
+
}));
|
|
142
139
|
mkdirSync(dirname(schemaFilePath), { recursive: true });
|
|
143
140
|
writeFileSync(schemaFilePath, schemaString, "utf-8");
|
|
144
141
|
} else if (hasUrlSchemas) {
|
|
145
|
-
const
|
|
142
|
+
const schemaString = printSchemaWithDirectives(loadSchemaSync(schemas, {
|
|
146
143
|
loaders: [new UrlLoader()],
|
|
147
144
|
...Object.keys(headers).length > 0 && { headers }
|
|
148
|
-
});
|
|
149
|
-
const schemaString = printSchemaWithDirectives(schema);
|
|
145
|
+
}));
|
|
150
146
|
mkdirSync(dirname(schemaFilePath), { recursive: true });
|
|
151
147
|
writeFileSync(schemaFilePath, schemaString, "utf-8");
|
|
152
148
|
} else if (hasLocalSchemas) {
|
|
153
|
-
const
|
|
154
|
-
const schemaString = printSchemaWithDirectives(schema);
|
|
149
|
+
const schemaString = printSchemaWithDirectives(loadSchemaSync(schemas, { loaders: [new GraphQLFileLoader()] }));
|
|
155
150
|
mkdirSync(dirname(schemaFilePath), { recursive: true });
|
|
156
151
|
writeFileSync(schemaFilePath, schemaString, "utf-8");
|
|
157
152
|
}
|
|
@@ -176,7 +171,7 @@ async function generateClientTypes(schema, docs, config = {}, sdkConfig = {}, ou
|
|
|
176
171
|
return false;
|
|
177
172
|
}
|
|
178
173
|
const serviceLabel = serviceName ? `:${serviceName}` : "";
|
|
179
|
-
const
|
|
174
|
+
const mergedConfig = defu$1({
|
|
180
175
|
emitLegacyCommonJSImports: false,
|
|
181
176
|
useTypeImports: true,
|
|
182
177
|
enumsAsTypes: true,
|
|
@@ -200,8 +195,7 @@ async function generateClientTypes(schema, docs, config = {}, sdkConfig = {}, ou
|
|
|
200
195
|
output: "File"
|
|
201
196
|
}
|
|
202
197
|
}
|
|
203
|
-
};
|
|
204
|
-
const mergedConfig = defu$1(defaultConfig, config);
|
|
198
|
+
}, config);
|
|
205
199
|
const mergedSdkConfig = defu$1(mergedConfig, sdkConfig);
|
|
206
200
|
try {
|
|
207
201
|
if (docs.length === 0) return {
|
|
@@ -271,15 +265,14 @@ export function getSdk(requester: Requester): Sdk {
|
|
|
271
265
|
typescriptGenericSdk: { plugin: plugin$1 }
|
|
272
266
|
}
|
|
273
267
|
});
|
|
274
|
-
const sdkContent = (await Promise.all(sdkOutput.map(async (config$1) => {
|
|
275
|
-
return {
|
|
276
|
-
file: config$1.filename,
|
|
277
|
-
content: await codegen(config$1)
|
|
278
|
-
};
|
|
279
|
-
})))[0]?.content || "";
|
|
280
268
|
return {
|
|
281
269
|
types: output,
|
|
282
|
-
sdk:
|
|
270
|
+
sdk: (await Promise.all(sdkOutput.map(async (config$1) => {
|
|
271
|
+
return {
|
|
272
|
+
file: config$1.filename,
|
|
273
|
+
content: await codegen(config$1)
|
|
274
|
+
};
|
|
275
|
+
})))[0]?.content || ""
|
|
283
276
|
};
|
|
284
277
|
} catch (error) {
|
|
285
278
|
consola$1.warn(`[graphql${serviceLabel}] Client type generation failed:`, error);
|
|
@@ -290,9 +283,7 @@ export function getSdk(requester: Requester): Sdk {
|
|
|
290
283
|
* Generate client types for external GraphQL service
|
|
291
284
|
*/
|
|
292
285
|
async function generateExternalClientTypes(service, schema, docs) {
|
|
293
|
-
|
|
294
|
-
const sdkConfig = service.codegen?.clientSDK || {};
|
|
295
|
-
return generateClientTypes(schema, docs, config, sdkConfig, void 0, service.name);
|
|
286
|
+
return generateClientTypes(schema, docs, service.codegen?.client || {}, service.codegen?.clientSDK || {}, void 0, service.name);
|
|
296
287
|
}
|
|
297
288
|
|
|
298
289
|
//#endregion
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GenImport } from "../types/index.js";
|
|
2
2
|
import { directiveParser, generateDirectiveSchema, generateDirectiveSchemas } from "./directive-parser.js";
|
|
3
|
-
import { Nitro } from "
|
|
3
|
+
import { Nitro } from "nitro/types";
|
|
4
4
|
|
|
5
5
|
//#region src/utils/index.d.ts
|
|
6
6
|
declare const GLOB_SCAN_PATTERN = "**/*.{graphql,gql,js,mjs,cjs,ts,mts,cts,tsx,jsx}";
|
package/dist/utils/index.js
CHANGED
|
@@ -143,9 +143,7 @@ async function scanDocs(nitro) {
|
|
|
143
143
|
const relativePath = f.path;
|
|
144
144
|
for (const pattern of externalPatterns) {
|
|
145
145
|
const clientDirPattern = `${nitro.graphql.dir.client}/`;
|
|
146
|
-
|
|
147
|
-
const fileDir = relativePath.split("/")[0];
|
|
148
|
-
if (patternDir === fileDir) return false;
|
|
146
|
+
if (pattern.replace(/* @__PURE__ */ new RegExp(`^${clientDirPattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`), "").split("/")[0] === relativePath.split("/")[0]) return false;
|
|
149
147
|
}
|
|
150
148
|
return true;
|
|
151
149
|
}).map((f) => f.fullPath);
|
|
@@ -21,7 +21,7 @@ function pluginContent(_schema, _documents, _config, _info) {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
async function generateTypes(selectFremework, schema, config = {}, outputPath) {
|
|
24
|
-
const
|
|
24
|
+
const mergedConfig = defu$1({
|
|
25
25
|
scalars: {
|
|
26
26
|
DateTime: DateTimeResolver.extensions.codegenScalarType,
|
|
27
27
|
DateTimeISO: DateTimeISOResolver.extensions.codegenScalarType,
|
|
@@ -43,8 +43,7 @@ async function generateTypes(selectFremework, schema, config = {}, outputPath) {
|
|
|
43
43
|
declarationKind: "interface",
|
|
44
44
|
enumsAsTypes: true,
|
|
45
45
|
...config.federation?.enabled && { federation: true }
|
|
46
|
-
};
|
|
47
|
-
const mergedConfig = defu$1(defaultConfig, config.codegen?.server);
|
|
46
|
+
}, config.codegen?.server);
|
|
48
47
|
return await codegen({
|
|
49
48
|
filename: outputPath || "types.generated.ts",
|
|
50
49
|
schema: parse(printSchemaWithDirectives(schema)),
|
|
@@ -61,7 +61,7 @@ function generateExternalOfetchClient(clientDir, serviceName, endpoint) {
|
|
|
61
61
|
if (!existsSync(serviceDir)) mkdirSync(serviceDir, { recursive: true });
|
|
62
62
|
if (!existsSync(ofetchPath)) {
|
|
63
63
|
const capitalizedServiceName = serviceName.charAt(0).toUpperCase() + serviceName.slice(1);
|
|
64
|
-
|
|
64
|
+
writeFileSync(ofetchPath, `// This file is auto-generated once by nitro-graphql for quick start
|
|
65
65
|
// You can modify this file according to your needs
|
|
66
66
|
import type { Sdk, Requester } from './sdk'
|
|
67
67
|
import { getSdk } from './sdk'
|
|
@@ -83,8 +83,7 @@ export function create${capitalizedServiceName}GraphQLClient(endpoint: string =
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
export const $${serviceName}Sdk: Sdk = getSdk(create${capitalizedServiceName}GraphQLClient())
|
|
87
|
-
writeFileSync(ofetchPath, ofetchContent, "utf-8");
|
|
86
|
+
export const $${serviceName}Sdk: Sdk = getSdk(create${capitalizedServiceName}GraphQLClient())`, "utf-8");
|
|
88
87
|
}
|
|
89
88
|
}
|
|
90
89
|
/**
|
|
@@ -251,8 +250,7 @@ async function generateMainClientTypes(nitro) {
|
|
|
251
250
|
return;
|
|
252
251
|
}
|
|
253
252
|
const graphqlString = readFileSync(schemaFilePath, "utf-8");
|
|
254
|
-
const
|
|
255
|
-
const types = await generateClientTypes(schema, loadDocs, nitro.options.graphql?.codegen?.client ?? {}, nitro.options.graphql?.codegen?.clientSDK ?? {});
|
|
253
|
+
const types = await generateClientTypes(nitro.options.graphql?.federation?.enabled === true ? buildSubgraphSchema([{ typeDefs: parse(graphqlString) }]) : buildSchema(graphqlString), loadDocs, nitro.options.graphql?.codegen?.client ?? {}, nitro.options.graphql?.codegen?.clientSDK ?? {});
|
|
256
254
|
if (types === false) return;
|
|
257
255
|
const clientTypesPath = resolve(nitro.options.buildDir, "types", "nitro-graphql-client.d.ts");
|
|
258
256
|
const defaultServiceDir = resolve(nitro.graphql.clientDir, "default");
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitro-graphql",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0-beta.1",
|
|
5
5
|
"description": "GraphQL integration for Nitro",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"@apollo/utils.withrequired": "^3.0.0",
|
|
64
64
|
"@as-integrations/h3": "^2.0.0",
|
|
65
65
|
"graphql": "^16.11.0",
|
|
66
|
-
"h3": "^1.
|
|
67
|
-
"
|
|
66
|
+
"h3": "^2.0.1-rc.2",
|
|
67
|
+
"nitro": "^3.0.1-alpha.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependenciesMeta": {
|
|
70
70
|
"@apollo/server": {
|
|
@@ -114,8 +114,8 @@
|
|
|
114
114
|
"eslint": "^9.37.0",
|
|
115
115
|
"graphql": "16.11.0",
|
|
116
116
|
"graphql-yoga": "^5.16.0",
|
|
117
|
-
"h3": "1.
|
|
118
|
-
"
|
|
117
|
+
"h3": "^2.0.1-rc.2",
|
|
118
|
+
"nitro": "^3.0.1-alpha.0",
|
|
119
119
|
"tsdown": "^0.15.6",
|
|
120
120
|
"typescript": "^5.9.3"
|
|
121
121
|
},
|