nitro-graphql 1.7.0-beta.0 → 1.7.0-beta.2
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/routes/apollo-server-ws.d.mts +2 -2
- package/dist/routes/apollo-server.d.mts +2 -2
- package/dist/routes/debug.d.mts +2 -2
- package/dist/routes/graphql-yoga-ws.d.mts +2 -2
- package/dist/routes/graphql-yoga.d.mts +2 -2
- package/dist/utils/client-codegen.d.mts +2 -3
- package/dist/utils/client-codegen.mjs +7 -13
- package/dist/utils/type-generation.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h33 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/apollo-server-ws.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: h33.EventHandler<h33.EventHandlerRequest, never>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h39 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/apollo-server.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: h39.EventHandler<h39.EventHandlerRequest, Promise<any>>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
package/dist/routes/debug.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h37 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/debug.d.ts
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ import * as h33 from "h3";
|
|
|
10
10
|
* - /_nitro/graphql/debug - HTML dashboard
|
|
11
11
|
* - /_nitro/graphql/debug?format=json - JSON API
|
|
12
12
|
*/
|
|
13
|
-
declare const _default:
|
|
13
|
+
declare const _default: h37.EventHandler<h37.EventHandlerRequest, Promise<string | {
|
|
14
14
|
timestamp: string;
|
|
15
15
|
environment: {
|
|
16
16
|
dev: any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h31 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/graphql-yoga-ws.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: h31.EventHandler<h31.EventHandlerRequest, never>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h30 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/graphql-yoga.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: h30.EventHandler<h30.EventHandlerRequest, Promise<Response>>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
|
@@ -23,7 +23,7 @@ declare function loadExternalSchema(service: ExternalGraphQLService, buildDir?:
|
|
|
23
23
|
*/
|
|
24
24
|
declare function downloadAndSaveSchema(service: ExternalGraphQLService, buildDir: string): Promise<string | undefined>;
|
|
25
25
|
declare function loadGraphQLDocuments(patterns: string | string[]): Promise<Source[]>;
|
|
26
|
-
declare function generateClientTypes(schema: GraphQLSchema, docs: Source[], config?: CodegenClientConfig, sdkConfig?: GenericSdkConfig, outputPath?: string, serviceName?: string, virtualTypesPath?: string): Promise<false | {
|
|
26
|
+
declare function generateClientTypes(schema: GraphQLSchema, docs: Source[], config?: CodegenClientConfig, sdkConfig?: GenericSdkConfig, outputPath?: string, serviceName?: string, virtualTypesPath?: string, subscriptionsEnabled?: boolean): Promise<false | {
|
|
27
27
|
types: string;
|
|
28
28
|
sdk: string;
|
|
29
29
|
}>;
|
|
@@ -39,7 +39,6 @@ declare function generateExternalClientTypes(service: ExternalGraphQLService, sc
|
|
|
39
39
|
*/
|
|
40
40
|
interface SubscriptionInfo {
|
|
41
41
|
name: string;
|
|
42
|
-
methodName: string;
|
|
43
42
|
fieldName: string;
|
|
44
43
|
hasVariables: boolean;
|
|
45
44
|
}
|
|
@@ -47,6 +46,6 @@ declare function extractSubscriptions(docs: Source[]): SubscriptionInfo[];
|
|
|
47
46
|
/**
|
|
48
47
|
* Generate subscription builder code (Drizzle-style API) + Vue Composables
|
|
49
48
|
*/
|
|
50
|
-
declare function generateSubscriptionBuilder(docs: Source[]): string;
|
|
49
|
+
declare function generateSubscriptionBuilder(docs: Source[], subscriptionsEnabled: boolean): string;
|
|
51
50
|
//#endregion
|
|
52
51
|
export { GraphQLLoadSchemaOptions, GraphQLTypeDefPointer, SubscriptionInfo, downloadAndSaveSchema, extractSubscriptions, generateClientTypes, generateExternalClientTypes, generateSubscriptionBuilder, graphQLLoadSchemaSync, loadExternalSchema, loadGraphQLDocuments };
|
|
@@ -165,7 +165,7 @@ async function loadGraphQLDocuments(patterns) {
|
|
|
165
165
|
else throw e;
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
async function generateClientTypes(schema, docs, config = {}, sdkConfig = {}, outputPath, serviceName, virtualTypesPath) {
|
|
168
|
+
async function generateClientTypes(schema, docs, config = {}, sdkConfig = {}, outputPath, serviceName, virtualTypesPath, subscriptionsEnabled) {
|
|
169
169
|
if (docs.length === 0 && !serviceName) {
|
|
170
170
|
consola$1.info("No client GraphQL files found. Skipping client type generation.");
|
|
171
171
|
return false;
|
|
@@ -271,7 +271,7 @@ export function getSdk(requester: Requester): Sdk {
|
|
|
271
271
|
content: await codegen(config$1)
|
|
272
272
|
};
|
|
273
273
|
})))[0]?.content || "";
|
|
274
|
-
const subscriptionBuilder = generateSubscriptionBuilder(docs);
|
|
274
|
+
const subscriptionBuilder = generateSubscriptionBuilder(docs, subscriptionsEnabled ?? false);
|
|
275
275
|
return {
|
|
276
276
|
types: output,
|
|
277
277
|
sdk: subscriptionBuilder ? sdkContent + subscriptionBuilder : sdkContent
|
|
@@ -285,13 +285,7 @@ export function getSdk(requester: Requester): Sdk {
|
|
|
285
285
|
* Generate client types for external GraphQL service
|
|
286
286
|
*/
|
|
287
287
|
async function generateExternalClientTypes(service, schema, docs, virtualTypesPath) {
|
|
288
|
-
return generateClientTypes(schema, docs, service.codegen?.client || {}, service.codegen?.clientSDK || {}, void 0, service.name, virtualTypesPath);
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Convert PascalCase to camelCase
|
|
292
|
-
*/
|
|
293
|
-
function toCamelCase(str) {
|
|
294
|
-
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
288
|
+
return generateClientTypes(schema, docs, service.codegen?.client || {}, service.codegen?.clientSDK || {}, void 0, service.name, virtualTypesPath, false);
|
|
295
289
|
}
|
|
296
290
|
function extractSubscriptions(docs) {
|
|
297
291
|
const subscriptions = [];
|
|
@@ -307,7 +301,6 @@ function extractSubscriptions(docs) {
|
|
|
307
301
|
const hasVariables = (operationDef.variableDefinitions?.length || 0) > 0;
|
|
308
302
|
subscriptions.push({
|
|
309
303
|
name,
|
|
310
|
-
methodName: toCamelCase(name),
|
|
311
304
|
fieldName,
|
|
312
305
|
hasVariables
|
|
313
306
|
});
|
|
@@ -318,7 +311,8 @@ function extractSubscriptions(docs) {
|
|
|
318
311
|
/**
|
|
319
312
|
* Generate subscription builder code (Drizzle-style API) + Vue Composables
|
|
320
313
|
*/
|
|
321
|
-
function generateSubscriptionBuilder(docs) {
|
|
314
|
+
function generateSubscriptionBuilder(docs, subscriptionsEnabled) {
|
|
315
|
+
if (!subscriptionsEnabled) return "";
|
|
322
316
|
const subscriptions = extractSubscriptions(docs);
|
|
323
317
|
if (subscriptions.length === 0) return "";
|
|
324
318
|
let output = `
|
|
@@ -438,11 +432,11 @@ function createSubscriptionBuilder<TData>(query: string, variables: unknown): Su
|
|
|
438
432
|
|
|
439
433
|
export const subscription = {
|
|
440
434
|
`;
|
|
441
|
-
for (const sub of subscriptions) if (sub.hasVariables) output += ` ${sub.
|
|
435
|
+
for (const sub of subscriptions) if (sub.hasVariables) output += ` ${sub.name}(variables: Types.${sub.name}SubscriptionVariables): SubscriptionBuilder<Types.${sub.name}Subscription['${sub.fieldName}']> {
|
|
442
436
|
return createSubscriptionBuilder<Types.${sub.name}Subscription['${sub.fieldName}']>(${sub.name}Document, variables)
|
|
443
437
|
},
|
|
444
438
|
`;
|
|
445
|
-
else output += ` ${sub.
|
|
439
|
+
else output += ` ${sub.name}(): SubscriptionBuilder<Types.${sub.name}Subscription['${sub.fieldName}']> {
|
|
446
440
|
return createSubscriptionBuilder<Types.${sub.name}Subscription['${sub.fieldName}']>(${sub.name}Document, undefined)
|
|
447
441
|
},
|
|
448
442
|
`;
|
|
@@ -284,7 +284,7 @@ async function generateMainClientTypes(nitro) {
|
|
|
284
284
|
return;
|
|
285
285
|
}
|
|
286
286
|
const graphqlString = readFileSync(schemaFilePath, "utf-8");
|
|
287
|
-
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 ?? {});
|
|
287
|
+
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 ?? {}, void 0, void 0, void 0, nitro.options.graphql?.subscriptions?.enabled ?? false);
|
|
288
288
|
if (types === false) return;
|
|
289
289
|
const placeholders = getDefaultPaths(nitro);
|
|
290
290
|
const typesConfig = getTypesConfig(nitro);
|