nitro-graphql 2.0.0-beta.54 → 2.0.0-beta.56
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/README.md +18 -813
- package/dist/core/constants.d.mts +2 -2
- package/dist/core/constants.mjs +2 -2
- package/dist/core/index.d.mts +2 -2
- package/dist/core/index.mjs +2 -2
- package/dist/core/manifest.mjs +3 -3
- package/dist/core/pubsub/index.d.mts +109 -0
- package/dist/core/pubsub/index.mjs +137 -0
- package/dist/core/scanning/common.mjs +1 -1
- package/dist/core/scanning/documents.d.mts +1 -1
- package/dist/core/scanning/documents.mjs +1 -1
- package/dist/core/scanning/schemas.d.mts +1 -1
- package/dist/core/scanning/schemas.mjs +1 -1
- package/dist/core/schema/builder.d.mts +2 -2
- package/dist/core/schema/builder.mjs +3 -3
- package/dist/core/schema/index.d.mts +2 -2
- package/dist/core/schema/index.mjs +2 -2
- package/dist/define.d.mts +2 -1
- package/dist/define.mjs +3 -1
- package/dist/nitro/codegen.mjs +9 -8
- package/dist/nitro/index.d.mts +2 -2
- package/dist/nitro/routes/apollo-server-ws.d.mts +16 -0
- package/dist/nitro/routes/apollo-server-ws.mjs +53 -0
- package/dist/nitro/routes/apollo-server.d.mts +2 -2
- package/dist/nitro/routes/debug.d.mts +2 -2
- package/dist/nitro/routes/graphql-yoga-ws.d.mts +13 -0
- package/dist/nitro/routes/graphql-yoga-ws.mjs +53 -0
- package/dist/nitro/routes/graphql-yoga.d.mts +2 -2
- package/dist/nitro/routes/health.d.mts +2 -2
- package/dist/nitro/setup/rollup-integration.mjs +5 -1
- package/dist/nitro/setup/routes.mjs +30 -10
- package/dist/nitro/setup/scanner.d.mts +2 -1
- package/dist/nitro/setup.mjs +4 -0
- package/dist/nitro/types.d.mts +81 -1
- package/dist/nitro/virtual/generators.d.mts +5 -1
- package/dist/nitro/virtual/generators.mjs +18 -2
- package/dist/nitro/virtual/stubs.d.mts +2 -1
- package/dist/nitro/virtual/stubs.mjs +2 -1
- package/native/index.js +52 -52
- package/package.json +19 -6
|
@@ -37,9 +37,9 @@ declare const DIRECTIVE_EXTENSIONS: readonly [".directive.ts", ".directive.js"];
|
|
|
37
37
|
*/
|
|
38
38
|
declare const GLOB_SCAN_PATTERN: "**/*.{graphql,gql,js,mjs,cjs,ts,mts,cts,tsx,jsx}";
|
|
39
39
|
/**
|
|
40
|
-
* GraphQL file pattern for glob
|
|
40
|
+
* GraphQL file pattern for glob (supports both .graphql and .gql extensions)
|
|
41
41
|
*/
|
|
42
|
-
declare const GRAPHQL_GLOB_PATTERN: "**/*.graphql";
|
|
42
|
+
declare const GRAPHQL_GLOB_PATTERN: "**/*.{graphql,gql}";
|
|
43
43
|
/**
|
|
44
44
|
* Resolver file pattern for glob
|
|
45
45
|
*/
|
package/dist/core/constants.mjs
CHANGED
|
@@ -39,9 +39,9 @@ const DIRECTIVE_EXTENSIONS = [".directive.ts", ".directive.js"];
|
|
|
39
39
|
*/
|
|
40
40
|
const GLOB_SCAN_PATTERN = "**/*.{graphql,gql,js,mjs,cjs,ts,mts,cts,tsx,jsx}";
|
|
41
41
|
/**
|
|
42
|
-
* GraphQL file pattern for glob
|
|
42
|
+
* GraphQL file pattern for glob (supports both .graphql and .gql extensions)
|
|
43
43
|
*/
|
|
44
|
-
const GRAPHQL_GLOB_PATTERN = "**/*.graphql";
|
|
44
|
+
const GRAPHQL_GLOB_PATTERN = "**/*.{graphql,gql}";
|
|
45
45
|
/**
|
|
46
46
|
* Resolver file pattern for glob
|
|
47
47
|
*/
|
package/dist/core/index.d.mts
CHANGED
|
@@ -20,7 +20,7 @@ import { parseDirectiveCall, scanDirectivesCore } from "./scanning/directives.mj
|
|
|
20
20
|
import { ScanDocumentsOptions, scanDocumentsCore } from "./scanning/documents.mjs";
|
|
21
21
|
import { parseResolverCall, scanResolversCore } from "./scanning/resolvers.mjs";
|
|
22
22
|
import { scanGraphqlCore, scanSchemasCore } from "./scanning/schemas.mjs";
|
|
23
|
-
import { CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema } from "./schema/builder.mjs";
|
|
23
|
+
import { CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema, parse, subscribe, validate } from "./schema/builder.mjs";
|
|
24
24
|
import { loadFederationSupport, resetFederationCache, warnFederationUnavailable } from "./schema/federation.mjs";
|
|
25
25
|
import "./schema/index.mjs";
|
|
26
26
|
import { DirectiveFileRef, DirectiveParser, ParsedDirective, directiveParser, generateDirectiveSchema, generateDirectiveSchemas } from "./utils/directive-parser.mjs";
|
|
@@ -30,4 +30,4 @@ import { getImportId, relativeWithDot } from "./utils/imports.mjs";
|
|
|
30
30
|
import { createLogger, createSilentLogger, defaultLogger } from "./utils/logger.mjs";
|
|
31
31
|
import { OfetchTemplateOptions, generateOfetchTemplate } from "./utils/ofetch-templates.mjs";
|
|
32
32
|
import { validateExternalServices } from "./validation/external-services.mjs";
|
|
33
|
-
export { ASTScanConfig, BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, CODEGEN_EXTERNALS, ClientCodegenConfig, ClientCodegenInput, ClientCodegenResult, CoreClientUtilsConfig, CoreCodegenConfig, CoreConfig, CoreContext, CoreExternalService, CoreFederationConfig, CoreGraphQLOptions, CoreLogger, CorePathsConfig, CoreScaffoldConfig, CoreSdkConfig, CoreSecurityConfig, CoreTypesConfig, CreateCoreConfigOptions, CreateMergedSchemaOptions, DEFAULT_CLIENT_CODEGEN_CONFIG, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, DEFAULT_SERVER_CODEGEN_CONFIG, DEFAULT_SERVER_TYPES_PATH, DEFINE_DIRECTIVE, DEFINE_FIELD, DEFINE_FUNCTIONS, DEFINE_GRAPHQL_CONFIG, DEFINE_MUTATION, DEFINE_QUERY, DEFINE_RESOLVER, DEFINE_SCHEMA, DEFINE_SUBSCRIPTION, DIRECTIVE_EXTENSIONS, DIRECTIVE_GLOB_PATTERN, DIR_APP_GRAPHQL, DIR_BUILD_NITRO, DIR_BUILD_NUXT, DIR_CLIENT_GRAPHQL, DIR_EXTERNAL, DIR_ROUTES_GRAPHQL, DIR_SERVER_GRAPHQL, DIR_SERVER_GRAPHQL_WIN, DefineDirectiveConfig, DefineFunction, DirectiveArgument, DirectiveDefinition, DirectiveFileRef, DirectiveParser, DirectiveWrapper, ENDPOINT_DEBUG, ENDPOINT_GRAPHQL, ENDPOINT_HEALTH, ExternalServiceCodegenConfig, FEDERATION_EXTERNALS, FILE_CLIENT_TYPES, FILE_CONFIG_TS, FILE_CONTEXT_DTS, FILE_CONTEXT_TS, FILE_DIRECTIVES_GRAPHQL, FILE_GRAPHQL_CONFIG, FILE_GRAPHQL_DTS, FILE_INDEX_TS, FILE_OFETCH_TS, FILE_SCHEMA_GRAPHQL, FILE_SCHEMA_TS, FILE_SDK_TS, FILE_SERVER_TYPES, FRAMEWORK_NITRO, FRAMEWORK_NUXT, FRAMEWORK_STANDALONE, Flatten, Framework, GENERATED_FILE_HEADER, GLOB_SCAN_PATTERN, GRAPHQL_EXTENSIONS, GRAPHQL_FRAMEWORK_APOLLO, GRAPHQL_FRAMEWORK_YOGA, GRAPHQL_GLOB_PATTERN, GRAPHQL_HTTP_METHODS, GraphQLArgumentType, GraphQLBaseType, GraphQLFramework, GraphQLLoadSchemaOptions, GraphQLScalarType, GraphQLTypeDefPointer, HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_INTERNAL_ERROR, LOG_TAG, MaskErrorOptions, ModuleConfig, OfetchTemplateOptions, PATTERN_CLIENT_EXTERNAL_TYPES, PLACEHOLDER_BUILD_DIR, PLACEHOLDER_CLIENT_DIR, PLACEHOLDER_FRAMEWORK, PLACEHOLDER_ROOT_DIR, PLACEHOLDER_SERVER_DIR, PLACEHOLDER_SERVICE_NAME, PLACEHOLDER_TYPES_DIR, PackageConfig, ParsedDirective, RESOLVER_EXTENSIONS, RESOLVER_GLOB_PATTERN, RESOLVER_TYPE_DIRECTIVE, RESOLVER_TYPE_MUTATION, RESOLVER_TYPE_QUERY, RESOLVER_TYPE_RESOLVER, RESOLVER_TYPE_SUBSCRIPTION, RESOLVER_TYPE_TYPE, ResolvedExtend, ResolvedPackage, ResolverDefinition, ResolverImport, ResolverType, SERVICE_DEFAULT, ScalarType, ScanContext, ScanDocumentsOptions, ScanResult, ScannedFile, ScannedResolver, SchemaDefinition, SchemaLoadOptions, SdkCodegenConfig, ServerCodegenConfig, ServerCodegenInput, ServerCodegenResult, buildGraphQLSchema, createCoreConfig, createCoreContext, createDefaultMaskError, createLogger, createMergedSchema, createScanContext, createSilentLogger, deduplicateFiles, defaultLogger, directiveParser, downloadAndSaveSchema, ensureDir, extractPaths, filterByExtension, generateClientTypesCore, generateDirectiveSchema, generateDirectiveSchemas, generateExternalClientTypesCore, generateOfetchTemplate, generateResolverModule, generateRuntimeIndex, generateSchemaModule, generateServerTypesCore, generateTypes, getImportId, graphQLLoadSchemaSync, isLocalPath, loadExternalSchema, loadFederationSupport, loadGraphQLDocuments, loadPackageConfig, mergeGraphQLOptions, parseDirectiveCall, parseResolverCall, parseSingleFile, pluginContent, readFileSafe, relativeWithDot, resetFederationCache, resolvePackageFiles, scanDirectivesCore, scanDirectory, scanDocumentsCore, scanGraphqlCore, scanResolversCore, scanSchemasCore, scanWithAST, validateExternalServices, validateNoDuplicateTypes, validateSchemaFiles, warnFederationUnavailable, writeFile, writeFileIfChanged };
|
|
33
|
+
export { ASTScanConfig, BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, CODEGEN_EXTERNALS, ClientCodegenConfig, ClientCodegenInput, ClientCodegenResult, CoreClientUtilsConfig, CoreCodegenConfig, CoreConfig, CoreContext, CoreExternalService, CoreFederationConfig, CoreGraphQLOptions, CoreLogger, CorePathsConfig, CoreScaffoldConfig, CoreSdkConfig, CoreSecurityConfig, CoreTypesConfig, CreateCoreConfigOptions, CreateMergedSchemaOptions, DEFAULT_CLIENT_CODEGEN_CONFIG, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, DEFAULT_SERVER_CODEGEN_CONFIG, DEFAULT_SERVER_TYPES_PATH, DEFINE_DIRECTIVE, DEFINE_FIELD, DEFINE_FUNCTIONS, DEFINE_GRAPHQL_CONFIG, DEFINE_MUTATION, DEFINE_QUERY, DEFINE_RESOLVER, DEFINE_SCHEMA, DEFINE_SUBSCRIPTION, DIRECTIVE_EXTENSIONS, DIRECTIVE_GLOB_PATTERN, DIR_APP_GRAPHQL, DIR_BUILD_NITRO, DIR_BUILD_NUXT, DIR_CLIENT_GRAPHQL, DIR_EXTERNAL, DIR_ROUTES_GRAPHQL, DIR_SERVER_GRAPHQL, DIR_SERVER_GRAPHQL_WIN, DefineDirectiveConfig, DefineFunction, DirectiveArgument, DirectiveDefinition, DirectiveFileRef, DirectiveParser, DirectiveWrapper, ENDPOINT_DEBUG, ENDPOINT_GRAPHQL, ENDPOINT_HEALTH, ExternalServiceCodegenConfig, FEDERATION_EXTERNALS, FILE_CLIENT_TYPES, FILE_CONFIG_TS, FILE_CONTEXT_DTS, FILE_CONTEXT_TS, FILE_DIRECTIVES_GRAPHQL, FILE_GRAPHQL_CONFIG, FILE_GRAPHQL_DTS, FILE_INDEX_TS, FILE_OFETCH_TS, FILE_SCHEMA_GRAPHQL, FILE_SCHEMA_TS, FILE_SDK_TS, FILE_SERVER_TYPES, FRAMEWORK_NITRO, FRAMEWORK_NUXT, FRAMEWORK_STANDALONE, Flatten, Framework, GENERATED_FILE_HEADER, GLOB_SCAN_PATTERN, GRAPHQL_EXTENSIONS, GRAPHQL_FRAMEWORK_APOLLO, GRAPHQL_FRAMEWORK_YOGA, GRAPHQL_GLOB_PATTERN, GRAPHQL_HTTP_METHODS, GraphQLArgumentType, GraphQLBaseType, GraphQLFramework, GraphQLLoadSchemaOptions, GraphQLScalarType, GraphQLTypeDefPointer, HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_INTERNAL_ERROR, LOG_TAG, MaskErrorOptions, ModuleConfig, OfetchTemplateOptions, PATTERN_CLIENT_EXTERNAL_TYPES, PLACEHOLDER_BUILD_DIR, PLACEHOLDER_CLIENT_DIR, PLACEHOLDER_FRAMEWORK, PLACEHOLDER_ROOT_DIR, PLACEHOLDER_SERVER_DIR, PLACEHOLDER_SERVICE_NAME, PLACEHOLDER_TYPES_DIR, PackageConfig, ParsedDirective, RESOLVER_EXTENSIONS, RESOLVER_GLOB_PATTERN, RESOLVER_TYPE_DIRECTIVE, RESOLVER_TYPE_MUTATION, RESOLVER_TYPE_QUERY, RESOLVER_TYPE_RESOLVER, RESOLVER_TYPE_SUBSCRIPTION, RESOLVER_TYPE_TYPE, ResolvedExtend, ResolvedPackage, ResolverDefinition, ResolverImport, ResolverType, SERVICE_DEFAULT, ScalarType, ScanContext, ScanDocumentsOptions, ScanResult, ScannedFile, ScannedResolver, SchemaDefinition, SchemaLoadOptions, SdkCodegenConfig, ServerCodegenConfig, ServerCodegenInput, ServerCodegenResult, buildGraphQLSchema, createCoreConfig, createCoreContext, createDefaultMaskError, createLogger, createMergedSchema, createScanContext, createSilentLogger, deduplicateFiles, defaultLogger, directiveParser, downloadAndSaveSchema, ensureDir, extractPaths, filterByExtension, generateClientTypesCore, generateDirectiveSchema, generateDirectiveSchemas, generateExternalClientTypesCore, generateOfetchTemplate, generateResolverModule, generateRuntimeIndex, generateSchemaModule, generateServerTypesCore, generateTypes, getImportId, graphQLLoadSchemaSync, isLocalPath, loadExternalSchema, loadFederationSupport, loadGraphQLDocuments, loadPackageConfig, mergeGraphQLOptions, parse, parseDirectiveCall, parseResolverCall, parseSingleFile, pluginContent, readFileSafe, relativeWithDot, resetFederationCache, resolvePackageFiles, scanDirectivesCore, scanDirectory, scanDocumentsCore, scanGraphqlCore, scanResolversCore, scanSchemasCore, scanWithAST, subscribe, validate, validateExternalServices, validateNoDuplicateTypes, validateSchemaFiles, warnFederationUnavailable, writeFile, writeFileIfChanged };
|
package/dist/core/index.mjs
CHANGED
|
@@ -17,11 +17,11 @@ import { scanDocumentsCore } from "./scanning/documents.mjs";
|
|
|
17
17
|
import { parseResolverCall, scanResolversCore } from "./scanning/resolvers.mjs";
|
|
18
18
|
import { scanGraphqlCore, scanSchemasCore } from "./scanning/schemas.mjs";
|
|
19
19
|
import { loadFederationSupport, resetFederationCache, warnFederationUnavailable } from "./schema/federation.mjs";
|
|
20
|
-
import { buildGraphQLSchema, createMergedSchema } from "./schema/builder.mjs";
|
|
20
|
+
import { buildGraphQLSchema, createMergedSchema, parse, subscribe, validate } from "./schema/builder.mjs";
|
|
21
21
|
import { DirectiveParser, directiveParser, generateDirectiveSchema, generateDirectiveSchemas } from "./utils/directive-parser.mjs";
|
|
22
22
|
import { createDefaultMaskError } from "./utils/errors.mjs";
|
|
23
23
|
import { getImportId, relativeWithDot } from "./utils/imports.mjs";
|
|
24
24
|
import { generateOfetchTemplate } from "./utils/ofetch-templates.mjs";
|
|
25
25
|
import { validateExternalServices } from "./validation/external-services.mjs";
|
|
26
26
|
|
|
27
|
-
export { BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, CODEGEN_EXTERNALS, DEFAULT_CLIENT_CODEGEN_CONFIG, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, DEFAULT_SERVER_CODEGEN_CONFIG, DEFAULT_SERVER_TYPES_PATH, DEFINE_DIRECTIVE, DEFINE_FIELD, DEFINE_FUNCTIONS, DEFINE_GRAPHQL_CONFIG, DEFINE_MUTATION, DEFINE_QUERY, DEFINE_RESOLVER, DEFINE_SCHEMA, DEFINE_SUBSCRIPTION, DIRECTIVE_EXTENSIONS, DIRECTIVE_GLOB_PATTERN, DIR_APP_GRAPHQL, DIR_BUILD_NITRO, DIR_BUILD_NUXT, DIR_CLIENT_GRAPHQL, DIR_EXTERNAL, DIR_ROUTES_GRAPHQL, DIR_SERVER_GRAPHQL, DIR_SERVER_GRAPHQL_WIN, DirectiveParser, ENDPOINT_DEBUG, ENDPOINT_GRAPHQL, ENDPOINT_HEALTH, FEDERATION_EXTERNALS, FILE_CLIENT_TYPES, FILE_CONFIG_TS, FILE_CONTEXT_DTS, FILE_CONTEXT_TS, FILE_DIRECTIVES_GRAPHQL, FILE_GRAPHQL_CONFIG, FILE_GRAPHQL_DTS, FILE_INDEX_TS, FILE_OFETCH_TS, FILE_SCHEMA_GRAPHQL, FILE_SCHEMA_TS, FILE_SDK_TS, FILE_SERVER_TYPES, FRAMEWORK_NITRO, FRAMEWORK_NUXT, FRAMEWORK_STANDALONE, GENERATED_FILE_HEADER, GLOB_SCAN_PATTERN, GRAPHQL_EXTENSIONS, GRAPHQL_FRAMEWORK_APOLLO, GRAPHQL_FRAMEWORK_YOGA, GRAPHQL_GLOB_PATTERN, GRAPHQL_HTTP_METHODS, HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_INTERNAL_ERROR, LOG_TAG, PATTERN_CLIENT_EXTERNAL_TYPES, PLACEHOLDER_BUILD_DIR, PLACEHOLDER_CLIENT_DIR, PLACEHOLDER_FRAMEWORK, PLACEHOLDER_ROOT_DIR, PLACEHOLDER_SERVER_DIR, PLACEHOLDER_SERVICE_NAME, PLACEHOLDER_TYPES_DIR, RESOLVER_EXTENSIONS, RESOLVER_GLOB_PATTERN, RESOLVER_TYPE_DIRECTIVE, RESOLVER_TYPE_MUTATION, RESOLVER_TYPE_QUERY, RESOLVER_TYPE_RESOLVER, RESOLVER_TYPE_SUBSCRIPTION, RESOLVER_TYPE_TYPE, SERVICE_DEFAULT, buildGraphQLSchema, createCoreConfig, createCoreContext, createDefaultMaskError, createLogger, createMergedSchema, createScanContext, createSilentLogger, deduplicateFiles, defaultLogger, directiveParser, downloadAndSaveSchema, ensureDir, extractPaths, filterByExtension, generateClientTypesCore, generateDirectiveSchema, generateDirectiveSchemas, generateExternalClientTypesCore, generateOfetchTemplate, generateResolverModule, generateRuntimeIndex, generateSchemaModule, generateServerTypesCore, generateTypes, getImportId, graphQLLoadSchemaSync, isLocalPath, loadExternalSchema, loadFederationSupport, loadGraphQLDocuments, loadPackageConfig, mergeGraphQLOptions, parseDirectiveCall, parseResolverCall, parseSingleFile, pluginContent, readFileSafe, relativeWithDot, resetFederationCache, resolvePackageFiles, scanDirectivesCore, scanDirectory, scanDocumentsCore, scanGraphqlCore, scanResolversCore, scanSchemasCore, scanWithAST, validateExternalServices, validateNoDuplicateTypes, validateSchemaFiles, warnFederationUnavailable, writeFile, writeFileIfChanged };
|
|
27
|
+
export { BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, CODEGEN_EXTERNALS, DEFAULT_CLIENT_CODEGEN_CONFIG, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, DEFAULT_SERVER_CODEGEN_CONFIG, DEFAULT_SERVER_TYPES_PATH, DEFINE_DIRECTIVE, DEFINE_FIELD, DEFINE_FUNCTIONS, DEFINE_GRAPHQL_CONFIG, DEFINE_MUTATION, DEFINE_QUERY, DEFINE_RESOLVER, DEFINE_SCHEMA, DEFINE_SUBSCRIPTION, DIRECTIVE_EXTENSIONS, DIRECTIVE_GLOB_PATTERN, DIR_APP_GRAPHQL, DIR_BUILD_NITRO, DIR_BUILD_NUXT, DIR_CLIENT_GRAPHQL, DIR_EXTERNAL, DIR_ROUTES_GRAPHQL, DIR_SERVER_GRAPHQL, DIR_SERVER_GRAPHQL_WIN, DirectiveParser, ENDPOINT_DEBUG, ENDPOINT_GRAPHQL, ENDPOINT_HEALTH, FEDERATION_EXTERNALS, FILE_CLIENT_TYPES, FILE_CONFIG_TS, FILE_CONTEXT_DTS, FILE_CONTEXT_TS, FILE_DIRECTIVES_GRAPHQL, FILE_GRAPHQL_CONFIG, FILE_GRAPHQL_DTS, FILE_INDEX_TS, FILE_OFETCH_TS, FILE_SCHEMA_GRAPHQL, FILE_SCHEMA_TS, FILE_SDK_TS, FILE_SERVER_TYPES, FRAMEWORK_NITRO, FRAMEWORK_NUXT, FRAMEWORK_STANDALONE, GENERATED_FILE_HEADER, GLOB_SCAN_PATTERN, GRAPHQL_EXTENSIONS, GRAPHQL_FRAMEWORK_APOLLO, GRAPHQL_FRAMEWORK_YOGA, GRAPHQL_GLOB_PATTERN, GRAPHQL_HTTP_METHODS, HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_INTERNAL_ERROR, LOG_TAG, PATTERN_CLIENT_EXTERNAL_TYPES, PLACEHOLDER_BUILD_DIR, PLACEHOLDER_CLIENT_DIR, PLACEHOLDER_FRAMEWORK, PLACEHOLDER_ROOT_DIR, PLACEHOLDER_SERVER_DIR, PLACEHOLDER_SERVICE_NAME, PLACEHOLDER_TYPES_DIR, RESOLVER_EXTENSIONS, RESOLVER_GLOB_PATTERN, RESOLVER_TYPE_DIRECTIVE, RESOLVER_TYPE_MUTATION, RESOLVER_TYPE_QUERY, RESOLVER_TYPE_RESOLVER, RESOLVER_TYPE_SUBSCRIPTION, RESOLVER_TYPE_TYPE, SERVICE_DEFAULT, buildGraphQLSchema, createCoreConfig, createCoreContext, createDefaultMaskError, createLogger, createMergedSchema, createScanContext, createSilentLogger, deduplicateFiles, defaultLogger, directiveParser, downloadAndSaveSchema, ensureDir, extractPaths, filterByExtension, generateClientTypesCore, generateDirectiveSchema, generateDirectiveSchemas, generateExternalClientTypesCore, generateOfetchTemplate, generateResolverModule, generateRuntimeIndex, generateSchemaModule, generateServerTypesCore, generateTypes, getImportId, graphQLLoadSchemaSync, isLocalPath, loadExternalSchema, loadFederationSupport, loadGraphQLDocuments, loadPackageConfig, mergeGraphQLOptions, parse, parseDirectiveCall, parseResolverCall, parseSingleFile, pluginContent, readFileSafe, relativeWithDot, resetFederationCache, resolvePackageFiles, scanDirectivesCore, scanDirectory, scanDocumentsCore, scanGraphqlCore, scanResolversCore, scanSchemasCore, scanWithAST, subscribe, validate, validateExternalServices, validateNoDuplicateTypes, validateSchemaFiles, warnFederationUnavailable, writeFile, writeFileIfChanged };
|
package/dist/core/manifest.mjs
CHANGED
|
@@ -77,9 +77,9 @@ async function resolvePackageFiles(pkg) {
|
|
|
77
77
|
const configPath = resolve(serverDir, "config.ts");
|
|
78
78
|
const schemaPath = resolve(serverDir, "schema.ts");
|
|
79
79
|
return {
|
|
80
|
-
schemas,
|
|
81
|
-
resolvers,
|
|
82
|
-
directives,
|
|
80
|
+
schemas: schemas.sort((a, b) => a.localeCompare(b)),
|
|
81
|
+
resolvers: resolvers.sort((a, b) => a.localeCompare(b)),
|
|
82
|
+
directives: directives.sort((a, b) => a.localeCompare(b)),
|
|
83
83
|
serverDir,
|
|
84
84
|
configPath: existsSync(configPath) ? configPath : void 0,
|
|
85
85
|
schemaPath: existsSync(schemaPath) ? schemaPath : void 0
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
//#region src/core/pubsub/index.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Built-in PubSub implementation for GraphQL Subscriptions
|
|
4
|
+
* Simple EventTarget-based implementation for single-instance deployments
|
|
5
|
+
*
|
|
6
|
+
* For multi-instance deployments, use external PubSub solutions like:
|
|
7
|
+
* - Redis (with ioredis)
|
|
8
|
+
* - Kafka
|
|
9
|
+
* - RabbitMQ
|
|
10
|
+
* - Cloud Pub/Sub services
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Generic PubSub engine interface
|
|
14
|
+
* Compatible with various PubSub implementations
|
|
15
|
+
*/
|
|
16
|
+
interface PubSubEngine<Topics extends Record<string, unknown> = Record<string, unknown>> {
|
|
17
|
+
/**
|
|
18
|
+
* Publish an event to a topic
|
|
19
|
+
* @param topic - Topic name to publish to
|
|
20
|
+
* @param payload - Event payload
|
|
21
|
+
*/
|
|
22
|
+
publish: <K extends keyof Topics>(topic: K, payload: Topics[K]) => Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Subscribe to a topic
|
|
25
|
+
* @param topic - Topic name to subscribe to
|
|
26
|
+
* @returns AsyncIterable that yields events
|
|
27
|
+
*/
|
|
28
|
+
subscribe: <K extends keyof Topics>(topic: K) => AsyncIterable<Topics[K]>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Type alias for typed PubSub instances
|
|
32
|
+
*/
|
|
33
|
+
type TypedPubSub<Topics extends Record<string, unknown>> = PubSubEngine<Topics>;
|
|
34
|
+
/**
|
|
35
|
+
* Create a simple in-memory PubSub instance
|
|
36
|
+
*
|
|
37
|
+
* This implementation uses EventTarget for lightweight pub/sub functionality.
|
|
38
|
+
* Suitable for:
|
|
39
|
+
* - Development environments
|
|
40
|
+
* - Single-instance production deployments
|
|
41
|
+
* - Testing
|
|
42
|
+
*
|
|
43
|
+
* NOT suitable for:
|
|
44
|
+
* - Multi-instance/clustered deployments (events won't propagate across instances)
|
|
45
|
+
* - High-throughput scenarios (consider Redis-based PubSub)
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* // Define your topic types
|
|
50
|
+
* interface MyTopics {
|
|
51
|
+
* 'user:created': { id: string; name: string }
|
|
52
|
+
* 'message:sent': { channelId: string; content: string }
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* // Create typed PubSub instance
|
|
56
|
+
* const pubsub = createPubSub<MyTopics>()
|
|
57
|
+
*
|
|
58
|
+
* // Publish events
|
|
59
|
+
* await pubsub.publish('user:created', { id: '123', name: 'John' })
|
|
60
|
+
*
|
|
61
|
+
* // Subscribe to events (in a resolver)
|
|
62
|
+
* export const userSubscriptions = defineSubscription({
|
|
63
|
+
* userCreated: {
|
|
64
|
+
* subscribe: async function* () {
|
|
65
|
+
* yield* pubsub.subscribe('user:created')
|
|
66
|
+
* }
|
|
67
|
+
* }
|
|
68
|
+
* })
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
declare function createPubSub<Topics extends Record<string, unknown> = Record<string, unknown>>(): PubSubEngine<Topics>;
|
|
72
|
+
/**
|
|
73
|
+
* Filter subscription events based on a predicate
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* export const chatSubscriptions = defineSubscription({
|
|
78
|
+
* messageAdded: {
|
|
79
|
+
* subscribe: async function* (_, { channelId }) {
|
|
80
|
+
* yield* withFilter(
|
|
81
|
+
* pubsub.subscribe('message:added'),
|
|
82
|
+
* (message) => message.channelId === channelId
|
|
83
|
+
* )
|
|
84
|
+
* }
|
|
85
|
+
* }
|
|
86
|
+
* })
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
declare function withFilter<T>(asyncIterable: AsyncIterable<T>, filter: (value: T) => boolean | Promise<boolean>): AsyncIterable<T>;
|
|
90
|
+
/**
|
|
91
|
+
* Map subscription events to a different shape
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* export const chatSubscriptions = defineSubscription({
|
|
96
|
+
* messageAdded: {
|
|
97
|
+
* subscribe: async function* () {
|
|
98
|
+
* yield* mapAsyncIterator(
|
|
99
|
+
* pubsub.subscribe('message:added'),
|
|
100
|
+
* (event) => ({ messageAdded: event.message })
|
|
101
|
+
* )
|
|
102
|
+
* }
|
|
103
|
+
* }
|
|
104
|
+
* })
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
declare function mapAsyncIterator<T, U>(asyncIterable: AsyncIterable<T>, mapper: (value: T) => U | Promise<U>): AsyncIterable<U>;
|
|
108
|
+
//#endregion
|
|
109
|
+
export { PubSubEngine, TypedPubSub, createPubSub, mapAsyncIterator, withFilter };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
//#region src/core/pubsub/index.ts
|
|
2
|
+
/**
|
|
3
|
+
* Create a simple in-memory PubSub instance
|
|
4
|
+
*
|
|
5
|
+
* This implementation uses EventTarget for lightweight pub/sub functionality.
|
|
6
|
+
* Suitable for:
|
|
7
|
+
* - Development environments
|
|
8
|
+
* - Single-instance production deployments
|
|
9
|
+
* - Testing
|
|
10
|
+
*
|
|
11
|
+
* NOT suitable for:
|
|
12
|
+
* - Multi-instance/clustered deployments (events won't propagate across instances)
|
|
13
|
+
* - High-throughput scenarios (consider Redis-based PubSub)
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Define your topic types
|
|
18
|
+
* interface MyTopics {
|
|
19
|
+
* 'user:created': { id: string; name: string }
|
|
20
|
+
* 'message:sent': { channelId: string; content: string }
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* // Create typed PubSub instance
|
|
24
|
+
* const pubsub = createPubSub<MyTopics>()
|
|
25
|
+
*
|
|
26
|
+
* // Publish events
|
|
27
|
+
* await pubsub.publish('user:created', { id: '123', name: 'John' })
|
|
28
|
+
*
|
|
29
|
+
* // Subscribe to events (in a resolver)
|
|
30
|
+
* export const userSubscriptions = defineSubscription({
|
|
31
|
+
* userCreated: {
|
|
32
|
+
* subscribe: async function* () {
|
|
33
|
+
* yield* pubsub.subscribe('user:created')
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
* })
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
function createPubSub() {
|
|
40
|
+
const eventTarget = new EventTarget();
|
|
41
|
+
return {
|
|
42
|
+
async publish(topic, payload) {
|
|
43
|
+
const event = new CustomEvent(String(topic), { detail: payload });
|
|
44
|
+
eventTarget.dispatchEvent(event);
|
|
45
|
+
},
|
|
46
|
+
subscribe(topic) {
|
|
47
|
+
const topicStr = String(topic);
|
|
48
|
+
return { [Symbol.asyncIterator]() {
|
|
49
|
+
const queue = [];
|
|
50
|
+
let resolve = null;
|
|
51
|
+
let done = false;
|
|
52
|
+
const listener = (event) => {
|
|
53
|
+
const payload = event.detail;
|
|
54
|
+
if (resolve) {
|
|
55
|
+
resolve({
|
|
56
|
+
value: payload,
|
|
57
|
+
done: false
|
|
58
|
+
});
|
|
59
|
+
resolve = null;
|
|
60
|
+
} else queue.push(payload);
|
|
61
|
+
};
|
|
62
|
+
eventTarget.addEventListener(topicStr, listener);
|
|
63
|
+
return {
|
|
64
|
+
next() {
|
|
65
|
+
if (done) return Promise.resolve({
|
|
66
|
+
value: void 0,
|
|
67
|
+
done: true
|
|
68
|
+
});
|
|
69
|
+
if (queue.length > 0) return Promise.resolve({
|
|
70
|
+
value: queue.shift(),
|
|
71
|
+
done: false
|
|
72
|
+
});
|
|
73
|
+
return new Promise((r) => {
|
|
74
|
+
resolve = r;
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
return() {
|
|
78
|
+
done = true;
|
|
79
|
+
eventTarget.removeEventListener(topicStr, listener);
|
|
80
|
+
return Promise.resolve({
|
|
81
|
+
value: void 0,
|
|
82
|
+
done: true
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
throw(error) {
|
|
86
|
+
done = true;
|
|
87
|
+
eventTarget.removeEventListener(topicStr, listener);
|
|
88
|
+
return Promise.reject(error);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
} };
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Filter subscription events based on a predicate
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* export const chatSubscriptions = defineSubscription({
|
|
101
|
+
* messageAdded: {
|
|
102
|
+
* subscribe: async function* (_, { channelId }) {
|
|
103
|
+
* yield* withFilter(
|
|
104
|
+
* pubsub.subscribe('message:added'),
|
|
105
|
+
* (message) => message.channelId === channelId
|
|
106
|
+
* )
|
|
107
|
+
* }
|
|
108
|
+
* }
|
|
109
|
+
* })
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
async function* withFilter(asyncIterable, filter) {
|
|
113
|
+
for await (const value of asyncIterable) if (await filter(value)) yield value;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Map subscription events to a different shape
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* export const chatSubscriptions = defineSubscription({
|
|
121
|
+
* messageAdded: {
|
|
122
|
+
* subscribe: async function* () {
|
|
123
|
+
* yield* mapAsyncIterator(
|
|
124
|
+
* pubsub.subscribe('message:added'),
|
|
125
|
+
* (event) => ({ messageAdded: event.message })
|
|
126
|
+
* )
|
|
127
|
+
* }
|
|
128
|
+
* }
|
|
129
|
+
* })
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
async function* mapAsyncIterator(asyncIterable, mapper) {
|
|
133
|
+
for await (const value of asyncIterable) yield await mapper(value);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
//#endregion
|
|
137
|
+
export { createPubSub, mapAsyncIterator, withFilter };
|
|
@@ -61,7 +61,7 @@ function extractPaths(files) {
|
|
|
61
61
|
async function scanWithLayers(ctx, options) {
|
|
62
62
|
const mainFiles = await scanDirectory(ctx, options.mainDir, options.mainSubDir, options.pattern);
|
|
63
63
|
const layerFiles = await Promise.all((options.layerDirs || []).map((layerDir) => scanDirectory(ctx, layerDir, options.layerSubDir, options.pattern))).then((r) => r.flat());
|
|
64
|
-
return deduplicateFiles([...mainFiles, ...layerFiles]);
|
|
64
|
+
return deduplicateFiles([...mainFiles, ...layerFiles]).sort((a, b) => a.path.localeCompare(b.path));
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
//#endregion
|
|
@@ -13,7 +13,7 @@ interface ScanDocumentsOptions {
|
|
|
13
13
|
clientDirRelative?: string;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Scan for GraphQL client documents (.graphql) in client directory
|
|
16
|
+
* Scan for GraphQL client documents (.graphql, .gql) in client directory
|
|
17
17
|
* Excludes files from external service directories
|
|
18
18
|
*/
|
|
19
19
|
declare function scanDocumentsCore(ctx: ScanContext, options?: ScanDocumentsOptions): Promise<ScanResult<string>>;
|
|
@@ -4,7 +4,7 @@ import { relative } from "pathe";
|
|
|
4
4
|
|
|
5
5
|
//#region src/core/scanning/documents.ts
|
|
6
6
|
/**
|
|
7
|
-
* Scan for GraphQL client documents (.graphql) in client directory
|
|
7
|
+
* Scan for GraphQL client documents (.graphql, .gql) in client directory
|
|
8
8
|
* Excludes files from external service directories
|
|
9
9
|
*/
|
|
10
10
|
async function scanDocumentsCore(ctx, options = {}) {
|
|
@@ -3,7 +3,7 @@ import { ScanContext, ScanResult } from "../types/scanning.mjs";
|
|
|
3
3
|
//#region src/core/scanning/schemas.d.ts
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Scan for GraphQL schema files (.graphql) in server directory
|
|
6
|
+
* Scan for GraphQL schema files (.graphql, .gql) in server directory
|
|
7
7
|
*/
|
|
8
8
|
declare function scanSchemasCore(ctx: ScanContext): Promise<ScanResult<string>>;
|
|
9
9
|
/**
|
|
@@ -4,7 +4,7 @@ import { relative } from "pathe";
|
|
|
4
4
|
|
|
5
5
|
//#region src/core/scanning/schemas.ts
|
|
6
6
|
/**
|
|
7
|
-
* Scan for GraphQL schema files (.graphql) in server directory
|
|
7
|
+
* Scan for GraphQL schema files (.graphql, .gql) in server directory
|
|
8
8
|
*/
|
|
9
9
|
async function scanSchemasCore(ctx) {
|
|
10
10
|
const warnings = [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DirectiveDefinition } from "../types/define.mjs";
|
|
2
|
-
import { GraphQLSchema } from "graphql";
|
|
2
|
+
import { GraphQLSchema, parse, subscribe, validate } from "graphql";
|
|
3
3
|
|
|
4
4
|
//#region src/core/schema/builder.d.ts
|
|
5
5
|
|
|
@@ -50,4 +50,4 @@ declare function createMergedSchema(options: CreateMergedSchemaOptions): Promise
|
|
|
50
50
|
*/
|
|
51
51
|
declare function buildGraphQLSchema(schemaPaths: string[]): Promise<GraphQLSchema | null>;
|
|
52
52
|
//#endregion
|
|
53
|
-
export { CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema };
|
|
53
|
+
export { CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema, parse, subscribe, validate };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { loadFederationSupport, warnFederationUnavailable } from "./federation.mjs";
|
|
2
2
|
import { consola as consola$1 } from "consola";
|
|
3
|
-
import { buildSchema, parse, print } from "graphql";
|
|
3
|
+
import { buildSchema, parse, parse as parse$1, print, subscribe, validate } from "graphql";
|
|
4
4
|
import { readFileSync } from "node:fs";
|
|
5
5
|
import { mergeResolvers, mergeTypeDefs } from "@graphql-tools/merge";
|
|
6
6
|
import { makeExecutableSchema } from "@graphql-tools/schema";
|
|
@@ -24,7 +24,7 @@ async function createMergedSchema(options) {
|
|
|
24
24
|
if (federationEnabled) {
|
|
25
25
|
const buildSubgraph = await loadFederationSupport();
|
|
26
26
|
if (buildSubgraph) schema = buildSubgraph({
|
|
27
|
-
typeDefs: typeof typeDefs === "string" ? parse(typeDefs) : typeDefs,
|
|
27
|
+
typeDefs: typeof typeDefs === "string" ? parse$1(typeDefs) : typeDefs,
|
|
28
28
|
resolvers: mergedResolvers
|
|
29
29
|
});
|
|
30
30
|
else {
|
|
@@ -67,4 +67,4 @@ async function buildGraphQLSchema(schemaPaths) {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
//#endregion
|
|
70
|
-
export { buildGraphQLSchema, createMergedSchema };
|
|
70
|
+
export { buildGraphQLSchema, createMergedSchema, parse, subscribe, validate };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema } from "./builder.mjs";
|
|
1
|
+
import { CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema, parse, subscribe, validate } from "./builder.mjs";
|
|
2
2
|
import { loadFederationSupport, resetFederationCache, warnFederationUnavailable } from "./federation.mjs";
|
|
3
|
-
export { CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema, loadFederationSupport, resetFederationCache, warnFederationUnavailable };
|
|
3
|
+
export { CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema, loadFederationSupport, parse, resetFederationCache, subscribe, validate, warnFederationUnavailable };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { loadFederationSupport, resetFederationCache, warnFederationUnavailable } from "./federation.mjs";
|
|
2
|
-
import { buildGraphQLSchema, createMergedSchema } from "./builder.mjs";
|
|
2
|
+
import { buildGraphQLSchema, createMergedSchema, parse, subscribe, validate } from "./builder.mjs";
|
|
3
3
|
|
|
4
|
-
export { buildGraphQLSchema, createMergedSchema, loadFederationSupport, resetFederationCache, warnFederationUnavailable };
|
|
4
|
+
export { buildGraphQLSchema, createMergedSchema, loadFederationSupport, parse, resetFederationCache, subscribe, validate, warnFederationUnavailable };
|
package/dist/define.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PubSubEngine, TypedPubSub, createPubSub, mapAsyncIterator, withFilter } from "./core/pubsub/index.mjs";
|
|
1
2
|
import { DefineDirectiveConfig, DefineServerConfig, DirectiveDefinition, Flatten, StandardSchemaV1 } from "./nitro/types.mjs";
|
|
2
3
|
import { NPMConfig, Resolvers, ResolversTypes } from "#graphql/server";
|
|
3
4
|
|
|
@@ -291,4 +292,4 @@ declare function defineGraphQLConfig<T extends NPMConfig = NPMConfig>(config: Pa
|
|
|
291
292
|
*/
|
|
292
293
|
declare function defineDirective(config: DefineDirectiveConfig): DirectiveDefinition;
|
|
293
294
|
//#endregion
|
|
294
|
-
export { defineDirective, defineField, defineGraphQLConfig, defineMutation, defineQuery, defineResolver, defineSchema, defineSubscription };
|
|
295
|
+
export { type PubSubEngine, type TypedPubSub, createPubSub, defineDirective, defineField, defineGraphQLConfig, defineMutation, defineQuery, defineResolver, defineSchema, defineSubscription, mapAsyncIterator, withFilter };
|
package/dist/define.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createPubSub, mapAsyncIterator, withFilter } from "./core/pubsub/index.mjs";
|
|
2
|
+
|
|
1
3
|
//#region src/define.ts
|
|
2
4
|
/**
|
|
3
5
|
* Define schema extensions programmatically for GraphQL types.
|
|
@@ -320,4 +322,4 @@ function defineDirective(config) {
|
|
|
320
322
|
}
|
|
321
323
|
|
|
322
324
|
//#endregion
|
|
323
|
-
export { defineDirective, defineField, defineGraphQLConfig, defineMutation, defineQuery, defineResolver, defineSchema, defineSubscription };
|
|
325
|
+
export { createPubSub, defineDirective, defineField, defineGraphQLConfig, defineMutation, defineQuery, defineResolver, defineSchema, defineSubscription, mapAsyncIterator, withFilter };
|
package/dist/nitro/codegen.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { getDefaultPaths, getSdkConfig, getTypesConfig, resolveFilePath, shouldG
|
|
|
10
10
|
import consola from "consola";
|
|
11
11
|
import { join, resolve } from "pathe";
|
|
12
12
|
import { printSchemaWithDirectives } from "@graphql-tools/utils";
|
|
13
|
-
import { buildSchema, parse, print } from "graphql";
|
|
13
|
+
import { buildSchema, lexicographicSortSchema, parse, print } from "graphql";
|
|
14
14
|
import { existsSync, readFileSync } from "node:fs";
|
|
15
15
|
import { mergeTypeDefs } from "@graphql-tools/merge";
|
|
16
16
|
import { loadFilesSync } from "@graphql-tools/load-files";
|
|
@@ -39,9 +39,9 @@ async function generateServerTypes(nitro, options = {}) {
|
|
|
39
39
|
const allStrings = loadFilesSync(schemas).map((s) => typeof s === "string" ? s : s.loc?.source?.body || "");
|
|
40
40
|
const validSchemas = [];
|
|
41
41
|
const strings = [];
|
|
42
|
-
schemas.forEach((schema
|
|
42
|
+
schemas.forEach((schema, i) => {
|
|
43
43
|
if (allStrings[i]) {
|
|
44
|
-
validSchemas.push(schema
|
|
44
|
+
validSchemas.push(schema);
|
|
45
45
|
strings.push(allStrings[i]);
|
|
46
46
|
}
|
|
47
47
|
});
|
|
@@ -53,14 +53,14 @@ async function generateServerTypes(nitro, options = {}) {
|
|
|
53
53
|
if (!validateNoDuplicateTypes(validSchemas, strings)) return;
|
|
54
54
|
const merged = mergeTypeDefs([strings.join("\n\n")], { throwOnConflict: true });
|
|
55
55
|
const federation = nitro.options.graphql?.federation?.enabled === true;
|
|
56
|
-
const
|
|
56
|
+
const sortedSchema = lexicographicSortSchema(await buildSchemaFromString(print(merged), federation));
|
|
57
57
|
const result = await generateServerTypesCore({
|
|
58
58
|
framework: nitro.options.graphql?.framework || "graphql-yoga",
|
|
59
|
-
schema,
|
|
59
|
+
schema: sortedSchema,
|
|
60
60
|
config: nitro.options.graphql?.codegen?.server,
|
|
61
61
|
federationEnabled: federation
|
|
62
62
|
});
|
|
63
|
-
writeFile(resolve(nitro.graphql.buildDir, "schema.graphql"), printSchemaWithDirectives(
|
|
63
|
+
writeFile(resolve(nitro.graphql.buildDir, "schema.graphql"), printSchemaWithDirectives(sortedSchema));
|
|
64
64
|
const placeholders = getDefaultPaths(nitro);
|
|
65
65
|
const typesConfig = getTypesConfig(nitro);
|
|
66
66
|
const typesPath = resolveFilePath(typesConfig.server, typesConfig.enabled, true, "{typesDir}/nitro-graphql-server.d.ts", placeholders);
|
|
@@ -92,7 +92,7 @@ async function generateMainClientTypes(nitro, options = {}) {
|
|
|
92
92
|
const docs = await loadGraphQLDocuments(nitro.scanDocuments);
|
|
93
93
|
const federation = nitro.options.graphql?.federation?.enabled === true;
|
|
94
94
|
const types = await generateClientTypesCore({
|
|
95
|
-
schema: await buildSchemaFromString(readFileSync(schemaPath, "utf-8"), federation),
|
|
95
|
+
schema: lexicographicSortSchema(await buildSchemaFromString(readFileSync(schemaPath, "utf-8"), federation)),
|
|
96
96
|
documents: docs,
|
|
97
97
|
config: nitro.options.graphql?.codegen?.client,
|
|
98
98
|
sdkConfig: nitro.options.graphql?.codegen?.clientSDK,
|
|
@@ -122,12 +122,13 @@ async function generateExternalTypes(nitro, options = {}) {
|
|
|
122
122
|
consola.warn(`[${service.name}] Failed to load schema`);
|
|
123
123
|
continue;
|
|
124
124
|
}
|
|
125
|
+
const sortedSchema = lexicographicSortSchema(schema);
|
|
125
126
|
const docs = service.documents?.length ? await loadGraphQLDocuments(service.documents).catch(() => []) : [];
|
|
126
127
|
if (service.documents?.length && !docs.length) {
|
|
127
128
|
consola.warn(`[${service.name}] No documents found`);
|
|
128
129
|
continue;
|
|
129
130
|
}
|
|
130
|
-
const types = await generateExternalClientTypesCore(service,
|
|
131
|
+
const types = await generateExternalClientTypesCore(service, sortedSchema, docs);
|
|
131
132
|
if (types === false) continue;
|
|
132
133
|
const placeholders = {
|
|
133
134
|
...getDefaultPaths(nitro),
|
package/dist/nitro/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodegenClientConfig, CodegenServerConfig, DefineDirectiveConfig, DefineServerConfig, DirectiveArgument, DirectiveDefinition, ExtendSource, ExternalGraphQLService, ExternalServicePaths, FederationConfig, FileGenerationConfig, Flatten, GenImport, GenericSdkConfig, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType, NitroGraphQLOptions, SdkConfig, SecurityConfig, StandardSchemaV1, TypesConfig } from "./types.mjs";
|
|
1
|
+
import { CodegenClientConfig, CodegenServerConfig, DefineDirectiveConfig, DefineServerConfig, DirectiveArgument, DirectiveDefinition, ExtendSource, ExternalGraphQLService, ExternalServicePaths, FederationConfig, FileGenerationConfig, Flatten, GenImport, GenericSdkConfig, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType, NitroGraphQLOptions, PubSubConfig, SSETransportConfig, SdkConfig, SecurityConfig, StandardSchemaV1, SubscriptionsConfig, TypesConfig, WebSocketTransportConfig } from "./types.mjs";
|
|
2
2
|
import { NitroAdapter } from "./adapter.mjs";
|
|
3
3
|
import { resolveSecurityConfig } from "./setup/logging.mjs";
|
|
4
4
|
import { setupNitroGraphQL } from "./setup.mjs";
|
|
@@ -43,4 +43,4 @@ declare function graphqlModule(options?: NitroGraphQLOptions): Plugin & {
|
|
|
43
43
|
nitro?: NitroModule;
|
|
44
44
|
};
|
|
45
45
|
//#endregion
|
|
46
|
-
export { CodegenClientConfig, CodegenServerConfig, DefineDirectiveConfig, DefineServerConfig, DirectiveArgument, DirectiveDefinition, ExtendSource, ExternalGraphQLService, ExternalServicePaths, FederationConfig, FileGenerationConfig, Flatten, GenImport, GenericSdkConfig, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType, NitroAdapter, NitroGraphQLOptions, SdkConfig, SecurityConfig, StandardSchemaV1, TypesConfig, graphqlModule as default, resolveSecurityConfig, setupNitroGraphQL };
|
|
46
|
+
export { CodegenClientConfig, CodegenServerConfig, DefineDirectiveConfig, DefineServerConfig, DirectiveArgument, DirectiveDefinition, ExtendSource, ExternalGraphQLService, ExternalServicePaths, FederationConfig, FileGenerationConfig, Flatten, GenImport, GenericSdkConfig, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType, NitroAdapter, NitroGraphQLOptions, PubSubConfig, SSETransportConfig, SdkConfig, SecurityConfig, StandardSchemaV1, SubscriptionsConfig, TypesConfig, WebSocketTransportConfig, graphqlModule as default, resolveSecurityConfig, setupNitroGraphQL };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as nitro_deps_h31 from "nitro/deps/h3";
|
|
2
|
+
|
|
3
|
+
//#region src/nitro/routes/apollo-server-ws.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Apollo Server WebSocket handler for subscriptions
|
|
7
|
+
* Uses graphql-ws library with crossws adapter for proper protocol handling
|
|
8
|
+
*
|
|
9
|
+
* Note: This handler works independently from Apollo Server for subscriptions,
|
|
10
|
+
* as Apollo Server v5 requires separate WebSocket handling.
|
|
11
|
+
*
|
|
12
|
+
* @see https://github.com/enisdenjo/graphql-ws
|
|
13
|
+
*/
|
|
14
|
+
declare const _default: nitro_deps_h31.EventHandler<nitro_deps_h31.EventHandlerRequest, unknown>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { _default as default };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createMergedSchema } from "../../core/schema/builder.mjs";
|
|
2
|
+
import { defineWebSocketHandler } from "nitro/h3";
|
|
3
|
+
import { importedConfig } from "#nitro-graphql/graphql-config";
|
|
4
|
+
import { moduleConfig } from "#nitro-graphql/module-config";
|
|
5
|
+
import { directives } from "#nitro-graphql/server-directives";
|
|
6
|
+
import { resolvers } from "#nitro-graphql/server-resolvers";
|
|
7
|
+
import { schemas } from "#nitro-graphql/server-schemas";
|
|
8
|
+
import { handleProtocols } from "graphql-ws";
|
|
9
|
+
import { makeHooks } from "graphql-ws/use/crossws";
|
|
10
|
+
|
|
11
|
+
//#region src/nitro/routes/apollo-server-ws.ts
|
|
12
|
+
let schema = null;
|
|
13
|
+
/**
|
|
14
|
+
* Get or create the merged GraphQL schema
|
|
15
|
+
*/
|
|
16
|
+
async function getSchema() {
|
|
17
|
+
if (!schema) schema = await createMergedSchema({
|
|
18
|
+
schemas,
|
|
19
|
+
resolvers,
|
|
20
|
+
directives,
|
|
21
|
+
moduleConfig
|
|
22
|
+
});
|
|
23
|
+
return schema;
|
|
24
|
+
}
|
|
25
|
+
const hooks = {
|
|
26
|
+
upgrade(request) {
|
|
27
|
+
const selected = handleProtocols(request.headers.get("sec-websocket-protocol") || "");
|
|
28
|
+
if (selected) return { headers: { "Sec-WebSocket-Protocol": selected } };
|
|
29
|
+
return {};
|
|
30
|
+
},
|
|
31
|
+
...makeHooks({
|
|
32
|
+
schema: () => getSchema(),
|
|
33
|
+
context: async (ctx) => {
|
|
34
|
+
const baseContext = { connectionParams: ctx.connectionParams };
|
|
35
|
+
if (typeof importedConfig.context === "function") {
|
|
36
|
+
const userContext = await importedConfig.context(baseContext);
|
|
37
|
+
return {
|
|
38
|
+
...baseContext,
|
|
39
|
+
...userContext
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (importedConfig.context && typeof importedConfig.context === "object") return {
|
|
43
|
+
...baseContext,
|
|
44
|
+
...importedConfig.context
|
|
45
|
+
};
|
|
46
|
+
return baseContext;
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
};
|
|
50
|
+
var apollo_server_ws_default = defineWebSocketHandler(hooks);
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
export { apollo_server_ws_default as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as nitro_deps_h33 from "nitro/deps/h3";
|
|
2
2
|
|
|
3
3
|
//#region src/nitro/routes/apollo-server.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: nitro_deps_h33.EventHandlerWithFetch<nitro_deps_h33.EventHandlerRequest, Promise<any>>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as nitro_deps_h35 from "nitro/deps/h3";
|
|
2
2
|
|
|
3
3
|
//#region src/nitro/routes/debug.d.ts
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ import * as nitro_deps_h33 from "nitro/deps/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: nitro_deps_h35.EventHandlerWithFetch<nitro_deps_h35.EventHandlerRequest, Promise<string | {
|
|
14
14
|
timestamp: string;
|
|
15
15
|
environment: {
|
|
16
16
|
dev: any;
|