nitro-graphql 1.7.0-beta.2 → 1.7.0-beta.3

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.
@@ -1,6 +1,6 @@
1
- import * as h39 from "h3";
1
+ import * as h35 from "h3";
2
2
 
3
3
  //#region src/routes/apollo-server.d.ts
4
- declare const _default: h39.EventHandler<h39.EventHandlerRequest, Promise<any>>;
4
+ declare const _default: h35.EventHandler<h35.EventHandlerRequest, Promise<any>>;
5
5
  //#endregion
6
6
  export { _default as default };
@@ -1,4 +1,4 @@
1
- import * as h37 from "h3";
1
+ import * as h39 from "h3";
2
2
 
3
3
  //#region src/routes/debug.d.ts
4
4
 
@@ -10,7 +10,7 @@ import * as h37 from "h3";
10
10
  * - /_nitro/graphql/debug - HTML dashboard
11
11
  * - /_nitro/graphql/debug?format=json - JSON API
12
12
  */
13
- declare const _default: h37.EventHandler<h37.EventHandlerRequest, Promise<string | {
13
+ declare const _default: h39.EventHandler<h39.EventHandlerRequest, Promise<string | {
14
14
  timestamp: string;
15
15
  environment: {
16
16
  dev: any;
@@ -1,6 +1,6 @@
1
- import * as h31 from "h3";
1
+ import * as h37 from "h3";
2
2
 
3
3
  //#region src/routes/graphql-yoga-ws.d.ts
4
- declare const _default: h31.EventHandler<h31.EventHandlerRequest, never>;
4
+ declare const _default: h37.EventHandler<h37.EventHandlerRequest, never>;
5
5
  //#endregion
6
6
  export { _default as default };
@@ -1,7 +1,7 @@
1
- import * as h35 from "h3";
1
+ import * as h31 from "h3";
2
2
 
3
3
  //#region src/routes/health.d.ts
4
- declare const _default: h35.EventHandler<h35.EventHandlerRequest, Promise<{
4
+ declare const _default: h31.EventHandler<h31.EventHandlerRequest, Promise<{
5
5
  status: string;
6
6
  message: string;
7
7
  timestamp: string;
@@ -38,7 +38,10 @@ declare function generateExternalClientTypes(service: ExternalGraphQLService, sc
38
38
  * Extract subscription info from documents
39
39
  */
40
40
  interface SubscriptionInfo {
41
+ /** Original operation name from GraphQL document (used for method names) */
41
42
  name: string;
43
+ /** PascalCase version for type references (matches GraphQL codegen output) */
44
+ typeName: string;
42
45
  fieldName: string;
43
46
  hasVariables: boolean;
44
47
  }
@@ -287,6 +287,12 @@ export function getSdk(requester: Requester): Sdk {
287
287
  async function generateExternalClientTypes(service, schema, docs, virtualTypesPath) {
288
288
  return generateClientTypes(schema, docs, service.codegen?.client || {}, service.codegen?.clientSDK || {}, void 0, service.name, virtualTypesPath, false);
289
289
  }
290
+ /**
291
+ * Convert first character to uppercase (PascalCase)
292
+ */
293
+ function toPascalCase(str) {
294
+ return str.charAt(0).toUpperCase() + str.slice(1);
295
+ }
290
296
  function extractSubscriptions(docs) {
291
297
  const subscriptions = [];
292
298
  for (const doc of docs) {
@@ -301,6 +307,7 @@ function extractSubscriptions(docs) {
301
307
  const hasVariables = (operationDef.variableDefinitions?.length || 0) > 0;
302
308
  subscriptions.push({
303
309
  name,
310
+ typeName: toPascalCase(name),
304
311
  fieldName,
305
312
  hasVariables
306
313
  });
@@ -432,12 +439,12 @@ function createSubscriptionBuilder<TData>(query: string, variables: unknown): Su
432
439
 
433
440
  export const subscription = {
434
441
  `;
435
- for (const sub of subscriptions) if (sub.hasVariables) output += ` ${sub.name}(variables: Types.${sub.name}SubscriptionVariables): SubscriptionBuilder<Types.${sub.name}Subscription['${sub.fieldName}']> {
436
- return createSubscriptionBuilder<Types.${sub.name}Subscription['${sub.fieldName}']>(${sub.name}Document, variables)
442
+ for (const sub of subscriptions) if (sub.hasVariables) output += ` ${sub.name}(variables: Types.${sub.typeName}SubscriptionVariables): SubscriptionBuilder<Types.${sub.typeName}Subscription['${sub.fieldName}']> {
443
+ return createSubscriptionBuilder<Types.${sub.typeName}Subscription['${sub.fieldName}']>(${sub.typeName}Document, variables)
437
444
  },
438
445
  `;
439
- else output += ` ${sub.name}(): SubscriptionBuilder<Types.${sub.name}Subscription['${sub.fieldName}']> {
440
- return createSubscriptionBuilder<Types.${sub.name}Subscription['${sub.fieldName}']>(${sub.name}Document, undefined)
446
+ else output += ` ${sub.name}(): SubscriptionBuilder<Types.${sub.typeName}Subscription['${sub.fieldName}']> {
447
+ return createSubscriptionBuilder<Types.${sub.typeName}Subscription['${sub.fieldName}']>(${sub.typeName}Document, undefined)
441
448
  },
442
449
  `;
443
450
  output += `}
@@ -632,44 +639,44 @@ function createUseSubscription<TData, TVariables = undefined>(
632
639
  // === Subscription Return Types ===
633
640
  `;
634
641
  for (const sub of subscriptions) {
635
- const typeName = `Types.${sub.name}Subscription['${sub.fieldName}']`;
636
- output += `/** Return type for use${sub.name} composable */
637
- export type Use${sub.name}Return = UseSubscriptionReturn<${typeName}>
642
+ const typeName = `Types.${sub.typeName}Subscription['${sub.fieldName}']`;
643
+ output += `/** Return type for use${sub.typeName} composable */
644
+ export type Use${sub.typeName}Return = UseSubscriptionReturn<${typeName}>
638
645
  `;
639
646
  }
640
647
  output += `
641
648
  // === Vue Composables ===
642
649
  `;
643
650
  for (const sub of subscriptions) {
644
- const typeName = `Types.${sub.name}Subscription['${sub.fieldName}']`;
645
- const varsType = `Types.${sub.name}SubscriptionVariables`;
651
+ const typeName = `Types.${sub.typeName}Subscription['${sub.fieldName}']`;
652
+ const varsType = `Types.${sub.typeName}SubscriptionVariables`;
646
653
  if (sub.hasVariables) output += `/**
647
- * Vue composable for ${sub.name} subscription
654
+ * Vue composable for ${sub.typeName} subscription
648
655
  * @param variables - Subscription variables
649
656
  * @param options - Subscription options (immediate, onData, onError, session, etc.)
650
657
  * @returns Reactive subscription state: { data, error, isActive, state, start, stop, restart }
651
658
  */
652
- export function use${sub.name}(
659
+ export function use${sub.typeName}(
653
660
  variables: ${varsType},
654
661
  options?: UseSubscriptionOptions<${typeName}>,
655
- ): Use${sub.name}Return {
662
+ ): Use${sub.typeName}Return {
656
663
  return createUseSubscription<${typeName}, ${varsType}>(
657
- ${sub.name}Document,
664
+ ${sub.typeName}Document,
658
665
  () => variables,
659
666
  )(options)
660
667
  }
661
668
 
662
669
  `;
663
670
  else output += `/**
664
- * Vue composable for ${sub.name} subscription
671
+ * Vue composable for ${sub.typeName} subscription
665
672
  * @param options - Subscription options (immediate, onData, onError, session, etc.)
666
673
  * @returns Reactive subscription state: { data, error, isActive, state, start, stop, restart }
667
674
  */
668
- export function use${sub.name}(
675
+ export function use${sub.typeName}(
669
676
  options?: UseSubscriptionOptions<${typeName}>,
670
- ): Use${sub.name}Return {
677
+ ): Use${sub.typeName}Return {
671
678
  return createUseSubscription<${typeName}, undefined>(
672
- ${sub.name}Document,
679
+ ${sub.typeName}Document,
673
680
  () => undefined,
674
681
  )(options)
675
682
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nitro-graphql",
3
3
  "type": "module",
4
- "version": "1.7.0-beta.2",
4
+ "version": "1.7.0-beta.3",
5
5
  "description": "GraphQL integration for Nitro",
6
6
  "license": "MIT",
7
7
  "repository": {