nitro-graphql 1.0.6 → 1.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 +2 -2
- package/dist/graphql/server.d.ts +4 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +0 -9
- package/dist/routes/apollo-server.d.ts +2 -2
- package/dist/routes/graphql-yoga.d.ts +2 -2
- package/dist/routes/health.d.ts +2 -2
- package/dist/utils/define.d.ts +4 -4
- package/dist/utils/server-codegen.d.ts +1 -1
- package/dist/utils/server-codegen.js +5 -1
- package/dist/utils/type-generation.js +1 -1
- package/package.json +1 -1
package/dist/ecosystem/nuxt.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _nuxt_schema4 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_schema4.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { ModuleOptions, _default as default };
|
package/dist/graphql/server.d.ts
CHANGED
|
@@ -2,5 +2,8 @@
|
|
|
2
2
|
interface StandardSchemaV1 extends Record<string, any> {}
|
|
3
3
|
interface ResolversTypes extends Record<string, any> {}
|
|
4
4
|
interface Resolvers extends Record<string, any> {}
|
|
5
|
+
interface NPMConfig {
|
|
6
|
+
framework: 'any';
|
|
7
|
+
}
|
|
5
8
|
//#endregion
|
|
6
|
-
export { Resolvers, ResolversTypes, StandardSchemaV1 };
|
|
9
|
+
export { NPMConfig, Resolvers, ResolversTypes, StandardSchemaV1 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from "./types/standard-schema.js";
|
|
2
2
|
import { CodegenClientConfig, CodegenServerConfig, GenImport, GenericSdkConfig, NitroGraphQLOptions } from "./types/index.js";
|
|
3
|
-
import * as
|
|
3
|
+
import * as nitropack5 from "nitropack";
|
|
4
4
|
|
|
5
5
|
//#region src/index.d.ts
|
|
6
|
-
|
|
7
|
-
declare const _default: nitropack4.NitroModule;
|
|
6
|
+
declare const _default: nitropack5.NitroModule;
|
|
8
7
|
//#endregion
|
|
9
|
-
export { CodegenClientConfig, CodegenServerConfig, GenImport, GenericSdkConfig,
|
|
8
|
+
export { CodegenClientConfig, CodegenServerConfig, GenImport, GenericSdkConfig, NitroGraphQLOptions, StandardSchemaV1, _default as default };
|
package/dist/index.js
CHANGED
|
@@ -144,15 +144,6 @@ var src_default = defineNitroModule({
|
|
|
144
144
|
return `chunks/_/[name].mjs`;
|
|
145
145
|
};
|
|
146
146
|
});
|
|
147
|
-
const graphqlDtsContent = `// Auto-generated by nitro-graphql
|
|
148
|
-
|
|
149
|
-
import type { SchemaType } from './nitro-graphql-server.d.ts'
|
|
150
|
-
|
|
151
|
-
declare module 'nitro-graphql' {
|
|
152
|
-
type GraphQLFramework = '${nitro.options.graphql?.framework || "graphql-yoga"}'
|
|
153
|
-
}
|
|
154
|
-
`;
|
|
155
|
-
writeFileSync(join(typesDir, "graphql.d.ts"), graphqlDtsContent);
|
|
156
147
|
nitro.options.typescript.strict = true;
|
|
157
148
|
nitro.hooks.hook("types:extend", (types) => {
|
|
158
149
|
types.tsConfig ||= {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h36 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/apollo-server.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: h36.EventHandler<h36.EventHandlerRequest, any>;
|
|
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 };
|
package/dist/routes/health.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h32 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/health.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: h32.EventHandler<h32.EventHandlerRequest, Promise<{
|
|
5
5
|
status: string;
|
|
6
6
|
message: string;
|
|
7
7
|
timestamp: string;
|
package/dist/utils/define.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ApolloServerOptions } from "@apollo/server";
|
|
2
2
|
import { H3Event } from "h3";
|
|
3
3
|
import { YogaServerOptions } from "graphql-yoga";
|
|
4
|
-
import { Resolvers, ResolversTypes } from "#graphql/server";
|
|
5
|
-
import {
|
|
4
|
+
import { NPMConfig, Resolvers, ResolversTypes } from "#graphql/server";
|
|
5
|
+
import { StandardSchemaV1 } from "nitro-graphql";
|
|
6
6
|
|
|
7
7
|
//#region src/utils/define.d.ts
|
|
8
8
|
type Flatten<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;
|
|
@@ -15,7 +15,7 @@ declare function defineQuery(resolvers?: Resolvers['Query']): Resolvers;
|
|
|
15
15
|
declare function defineMutation(resolvers?: Resolvers['Mutation']): Resolvers;
|
|
16
16
|
declare function defineSubscription(resolvers?: Resolvers['Subscription']): Resolvers;
|
|
17
17
|
declare function defineType(resolvers: Resolvers): Resolvers;
|
|
18
|
-
type DefineServerConfig =
|
|
19
|
-
declare function defineGraphQLConfig(config: Partial<DefineServerConfig
|
|
18
|
+
type DefineServerConfig<T extends NPMConfig = NPMConfig> = T['framework'] extends 'graphql-yoga' ? Partial<YogaServerOptions<H3Event, Partial<H3Event>>> : T['framework'] extends 'apollo-server' ? Partial<ApolloServerOptions<H3Event>> : Partial<YogaServerOptions<H3Event, Partial<H3Event>>> | Partial<ApolloServerOptions<H3Event>>;
|
|
19
|
+
declare function defineGraphQLConfig<T extends NPMConfig = NPMConfig>(config: Partial<DefineServerConfig<T>>): Partial<DefineServerConfig<T>>;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { DefineServerConfig, ResolverQuery, defineGraphQLConfig, defineMutation, defineQuery, defineResolver, defineSchema, defineSubscription, defineType };
|
|
@@ -2,6 +2,6 @@ import { CodegenServerConfig } from "../types/index.js";
|
|
|
2
2
|
import { GraphQLSchema } from "graphql";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/server-codegen.d.ts
|
|
5
|
-
declare function generateTypes(schema: GraphQLSchema, config?: CodegenServerConfig, outputPath?: string): Promise<string>;
|
|
5
|
+
declare function generateTypes(selectFremework: string, schema: GraphQLSchema, config?: CodegenServerConfig, outputPath?: string): Promise<string>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { generateTypes };
|
|
@@ -20,7 +20,7 @@ function pluginContent(_schema, _documents, _config, _info) {
|
|
|
20
20
|
content: ""
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
async function generateTypes(schema, config = {}, outputPath) {
|
|
23
|
+
async function generateTypes(selectFremework, schema, config = {}, outputPath) {
|
|
24
24
|
const defaultConfig = {
|
|
25
25
|
scalars: {
|
|
26
26
|
DateTime: DateTimeResolver.extensions.codegenScalarType,
|
|
@@ -63,6 +63,10 @@ async function generateTypes(schema, config = {}, outputPath) {
|
|
|
63
63
|
`import schemas from '#graphql/schema'`,
|
|
64
64
|
`import type { StandardSchemaV1 } from 'nitro-graphql'`,
|
|
65
65
|
`
|
|
66
|
+
export interface NPMConfig {
|
|
67
|
+
framework: '${selectFremework || "graphql-yoga"}';
|
|
68
|
+
}
|
|
69
|
+
|
|
66
70
|
export type SchemaType = Partial<Record<Partial<keyof ResolversTypes>, StandardSchemaV1>>
|
|
67
71
|
|
|
68
72
|
// Check if schemas is empty object, return never if so
|
|
@@ -51,7 +51,7 @@ async function serverTypeGeneration(app) {
|
|
|
51
51
|
assumeValidSDL: true,
|
|
52
52
|
assumeValid: true
|
|
53
53
|
});
|
|
54
|
-
const data = await generateTypes(schema, app.options.graphql?.codegen?.server ?? {});
|
|
54
|
+
const data = await generateTypes(app.options.graphql?.framework || "graphql-yoga", schema, app.options.graphql?.codegen?.server ?? {});
|
|
55
55
|
const printSchema = printSchemaWithDirectives(schema);
|
|
56
56
|
const schemaPath = resolve(app.graphql.buildDir, "schema.graphql");
|
|
57
57
|
mkdirSync(dirname(schemaPath), { recursive: true });
|