nitro-graphql 2.0.0-beta.40 → 2.0.0-beta.41
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 +12 -15
- package/dist/cli/index.mjs +1 -1
- package/dist/config.d.mts +2 -0
- package/dist/config.mjs +3 -0
- package/dist/core/constants.d.mts +3 -3
- package/dist/core/constants.mjs +3 -3
- package/dist/core/index.d.mts +5 -4
- package/dist/core/index.mjs +5 -4
- package/dist/core/manifest.d.mts +46 -0
- package/dist/core/manifest.mjs +76 -0
- package/dist/core/scanning/ast-scanner.d.mts +6 -1
- package/dist/core/scanning/ast-scanner.mjs +20 -1
- package/dist/core/scanning/index.d.mts +3 -3
- package/dist/core/scanning/index.mjs +3 -3
- package/dist/core/scanning/resolvers.d.mts +7 -2
- package/dist/core/scanning/resolvers.mjs +2 -1
- package/dist/core/types/config.d.mts +2 -4
- package/dist/nitro/codegen.mjs +2 -2
- package/dist/nitro/config.d.mts +2 -3
- package/dist/nitro/config.mjs +2 -3
- package/dist/nitro/index.d.mts +2 -2
- package/dist/nitro/paths.d.mts +3 -3
- package/dist/nitro/paths.mjs +9 -10
- package/dist/nitro/routes/apollo-server.d.mts +2 -2
- package/dist/nitro/routes/debug.d.mts +2 -2
- package/dist/nitro/setup/extend-loader.d.mts +19 -0
- package/dist/nitro/setup/extend-loader.mjs +129 -0
- package/dist/nitro/setup/file-watcher.d.mts +1 -1
- package/dist/nitro/setup/file-watcher.mjs +20 -2
- package/dist/nitro/setup.mjs +8 -5
- package/dist/nitro/types.d.mts +20 -24
- package/dist/nitro/virtual/generators.mjs +1 -81
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -357,12 +357,9 @@ export default defineNitroConfig({
|
|
|
357
357
|
framework: 'graphql-yoga',
|
|
358
358
|
|
|
359
359
|
// Method 1: Global paths (affects all files)
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
buildDir: '.build',
|
|
364
|
-
typesDir: '.build/types',
|
|
365
|
-
},
|
|
360
|
+
serverDir: 'src/server/graphql',
|
|
361
|
+
clientDir: 'src/client/graphql',
|
|
362
|
+
typesDir: '.build/types',
|
|
366
363
|
|
|
367
364
|
// Method 2: Specific file paths
|
|
368
365
|
scaffold: {
|
|
@@ -395,13 +392,13 @@ Use placeholders in custom paths:
|
|
|
395
392
|
| `{rootDir}` | Root directory | `/Users/you/project` |
|
|
396
393
|
| `{framework}` | Framework name | `nuxt` or `nitro` |
|
|
397
394
|
| `{typesDir}` | Types directory | `.nitro/types` |
|
|
398
|
-
| `{
|
|
399
|
-
| `{
|
|
395
|
+
| `{serverDir}` | Server GraphQL dir | `server/graphql` |
|
|
396
|
+
| `{clientDir}` | Client GraphQL dir | `app/graphql` |
|
|
400
397
|
|
|
401
398
|
Example:
|
|
402
399
|
```ts
|
|
403
400
|
sdk: {
|
|
404
|
-
external: '{
|
|
401
|
+
external: '{clientDir}/{serviceName}/sdk.ts'
|
|
405
402
|
}
|
|
406
403
|
// → app/graphql/github/sdk.ts
|
|
407
404
|
// → app/graphql/stripe/sdk.ts
|
|
@@ -465,15 +462,15 @@ When resolving file paths, the system follows this priority order:
|
|
|
465
462
|
|
|
466
463
|
1. **Service-specific path** (for external services): `service.paths.sdk`
|
|
467
464
|
2. **Category config**: `sdk.external` or `sdk.main`
|
|
468
|
-
3. **Global paths**: `
|
|
465
|
+
3. **Global paths**: `clientDir`
|
|
469
466
|
4. **Framework defaults**: Nuxt vs Nitro defaults
|
|
470
467
|
|
|
471
468
|
Example:
|
|
472
469
|
```ts
|
|
473
470
|
// Given this config:
|
|
474
471
|
{
|
|
475
|
-
|
|
476
|
-
sdk: { external: '{
|
|
472
|
+
clientDir: 'custom/graphql',
|
|
473
|
+
sdk: { external: '{clientDir}/{serviceName}/sdk.ts' },
|
|
477
474
|
externalServices: [
|
|
478
475
|
{
|
|
479
476
|
name: 'github',
|
|
@@ -492,9 +489,9 @@ Example:
|
|
|
492
489
|
|
|
493
490
|
**Monorepo structure:**
|
|
494
491
|
```ts
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
492
|
+
{
|
|
493
|
+
serverDir: 'packages/api/src/graphql',
|
|
494
|
+
clientDir: 'packages/web/src/graphql',
|
|
498
495
|
typesDir: 'packages/types/src/generated',
|
|
499
496
|
}
|
|
500
497
|
```
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { LOG_TAG } from "../core/constants.mjs";
|
|
3
2
|
import { DEFAULT_CLI_CONFIG, defineConfig } from "./config.mjs";
|
|
3
|
+
import { LOG_TAG } from "../core/constants.mjs";
|
|
4
4
|
import consola from "consola";
|
|
5
5
|
import { resolve } from "pathe";
|
|
6
6
|
import { existsSync } from "node:fs";
|
package/dist/config.mjs
ADDED
|
@@ -169,8 +169,8 @@ declare const PLACEHOLDER_BUILD_DIR: "{buildDir}";
|
|
|
169
169
|
declare const PLACEHOLDER_ROOT_DIR: "{rootDir}";
|
|
170
170
|
declare const PLACEHOLDER_FRAMEWORK: "{framework}";
|
|
171
171
|
declare const PLACEHOLDER_TYPES_DIR: "{typesDir}";
|
|
172
|
-
declare const
|
|
173
|
-
declare const
|
|
172
|
+
declare const PLACEHOLDER_SERVER_DIR: "{serverDir}";
|
|
173
|
+
declare const PLACEHOLDER_CLIENT_DIR: "{clientDir}";
|
|
174
174
|
/**
|
|
175
175
|
* Logger tag for nitro-graphql module
|
|
176
176
|
*/
|
|
@@ -185,4 +185,4 @@ declare const HTTP_STATUS_INTERNAL_ERROR: 500;
|
|
|
185
185
|
*/
|
|
186
186
|
declare const SERVICE_DEFAULT: "default";
|
|
187
187
|
//#endregion
|
|
188
|
-
export { BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, CODEGEN_EXTERNALS, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, 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, DefineFunction, 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, Framework, GLOB_SCAN_PATTERN, GRAPHQL_EXTENSIONS, GRAPHQL_FRAMEWORK_APOLLO, GRAPHQL_FRAMEWORK_YOGA, GRAPHQL_GLOB_PATTERN, GRAPHQL_HTTP_METHODS, GraphQLFramework, HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_INTERNAL_ERROR, LOG_TAG, PATTERN_CLIENT_EXTERNAL_TYPES, PLACEHOLDER_BUILD_DIR,
|
|
188
|
+
export { BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, CODEGEN_EXTERNALS, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, 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, DefineFunction, 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, Framework, GLOB_SCAN_PATTERN, GRAPHQL_EXTENSIONS, GRAPHQL_FRAMEWORK_APOLLO, GRAPHQL_FRAMEWORK_YOGA, GRAPHQL_GLOB_PATTERN, GRAPHQL_HTTP_METHODS, GraphQLFramework, 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, ResolverType, SERVICE_DEFAULT };
|
package/dist/core/constants.mjs
CHANGED
|
@@ -190,8 +190,8 @@ const PLACEHOLDER_BUILD_DIR = "{buildDir}";
|
|
|
190
190
|
const PLACEHOLDER_ROOT_DIR = "{rootDir}";
|
|
191
191
|
const PLACEHOLDER_FRAMEWORK = "{framework}";
|
|
192
192
|
const PLACEHOLDER_TYPES_DIR = "{typesDir}";
|
|
193
|
-
const
|
|
194
|
-
const
|
|
193
|
+
const PLACEHOLDER_SERVER_DIR = "{serverDir}";
|
|
194
|
+
const PLACEHOLDER_CLIENT_DIR = "{clientDir}";
|
|
195
195
|
/**
|
|
196
196
|
* Logger tag for nitro-graphql module
|
|
197
197
|
*/
|
|
@@ -207,4 +207,4 @@ const HTTP_STATUS_INTERNAL_ERROR = 500;
|
|
|
207
207
|
const SERVICE_DEFAULT = "default";
|
|
208
208
|
|
|
209
209
|
//#endregion
|
|
210
|
-
export { BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, CODEGEN_EXTERNALS, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, 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, 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, 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,
|
|
210
|
+
export { BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, CODEGEN_EXTERNALS, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, 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, 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, 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 };
|
package/dist/core/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, CODEGEN_EXTERNALS, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, 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, DefineFunction, 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, Framework, GLOB_SCAN_PATTERN, GRAPHQL_EXTENSIONS, GRAPHQL_FRAMEWORK_APOLLO, GRAPHQL_FRAMEWORK_YOGA, GRAPHQL_GLOB_PATTERN, GRAPHQL_HTTP_METHODS, GraphQLFramework, HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_INTERNAL_ERROR, LOG_TAG, PATTERN_CLIENT_EXTERNAL_TYPES, PLACEHOLDER_BUILD_DIR,
|
|
1
|
+
import { BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, CODEGEN_EXTERNALS, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, 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, DefineFunction, 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, Framework, GLOB_SCAN_PATTERN, GRAPHQL_EXTENSIONS, GRAPHQL_FRAMEWORK_APOLLO, GRAPHQL_FRAMEWORK_YOGA, GRAPHQL_GLOB_PATTERN, GRAPHQL_HTTP_METHODS, GraphQLFramework, 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, ResolverType, SERVICE_DEFAULT } from "./constants.mjs";
|
|
2
2
|
import { ClientCodegenConfig, ClientCodegenInput, ClientCodegenResult, ExternalServiceCodegenConfig, ScalarType, SchemaLoadOptions, SdkCodegenConfig, ServerCodegenConfig, ServerCodegenInput, ServerCodegenResult } from "./types/codegen.mjs";
|
|
3
3
|
import { CoreClientUtilsConfig, CoreCodegenConfig, CoreConfig, CoreContext, CoreExternalService, CoreFederationConfig, CoreGraphQLOptions, CoreLogger, CorePathsConfig, CoreScaffoldConfig, CoreSdkConfig, CoreSecurityConfig, CoreTypesConfig } from "./types/config.mjs";
|
|
4
4
|
import { DefineDirectiveConfig, DirectiveArgument, DirectiveDefinition, Flatten, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType } from "./types/define.mjs";
|
|
@@ -13,11 +13,12 @@ import { DEFAULT_SERVER_CODEGEN_CONFIG, generateServerTypesCore, generateTypes }
|
|
|
13
13
|
import { validateNoDuplicateTypes } from "./codegen/validation.mjs";
|
|
14
14
|
import "./codegen/index.mjs";
|
|
15
15
|
import { CreateCoreConfigOptions, createCoreConfig, createCoreContext, createScanContext, mergeGraphQLOptions } from "./config.mjs";
|
|
16
|
-
import {
|
|
16
|
+
import { PackageConfig, ResolvedExtend, ResolvedPackage, loadPackageConfig, resolvePackageFiles } from "./manifest.mjs";
|
|
17
|
+
import { ASTScanConfig, parseSingleFile, scanWithAST } from "./scanning/ast-scanner.mjs";
|
|
17
18
|
import { deduplicateFiles, extractPaths, filterByExtension, scanDirectory } from "./scanning/common.mjs";
|
|
18
19
|
import { scanDirectivesCore } from "./scanning/directives.mjs";
|
|
19
20
|
import { ScanDocumentsOptions, scanDocumentsCore } from "./scanning/documents.mjs";
|
|
20
|
-
import { scanResolversCore } from "./scanning/resolvers.mjs";
|
|
21
|
+
import { parseResolverCall, scanResolversCore } from "./scanning/resolvers.mjs";
|
|
21
22
|
import { scanGraphqlCore, scanSchemasCore } from "./scanning/schemas.mjs";
|
|
22
23
|
import { CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema } from "./schema/builder.mjs";
|
|
23
24
|
import { loadFederationSupport, resetFederationCache, warnFederationUnavailable } from "./schema/federation.mjs";
|
|
@@ -29,4 +30,4 @@ import { getImportId, relativeWithDot } from "./utils/imports.mjs";
|
|
|
29
30
|
import { createLogger, createSilentLogger, defaultLogger } from "./utils/logger.mjs";
|
|
30
31
|
import { OfetchTemplateOptions, generateOfetchTemplate } from "./utils/ofetch-templates.mjs";
|
|
31
32
|
import { validateExternalServices } from "./validation/external-services.mjs";
|
|
32
|
-
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,
|
|
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, loadExternalSchema, loadFederationSupport, loadGraphQLDocuments, loadPackageConfig, mergeGraphQLOptions, parseResolverCall, parseSingleFile, pluginContent, readFileSafe, relativeWithDot, resetFederationCache, resolvePackageFiles, scanDirectivesCore, scanDirectory, scanDocumentsCore, scanGraphqlCore, scanResolversCore, scanSchemasCore, scanWithAST, validateExternalServices, validateNoDuplicateTypes, warnFederationUnavailable, writeFile, writeFileIfChanged };
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, CODEGEN_EXTERNALS, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, 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, 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, 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,
|
|
1
|
+
import { BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, CODEGEN_EXTERNALS, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, 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, 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, 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 } from "./constants.mjs";
|
|
2
2
|
import { GENERATED_FILE_HEADER, pluginContent } from "./codegen/plugin.mjs";
|
|
3
3
|
import { loadGraphQLDocuments } from "./codegen/document-loader.mjs";
|
|
4
4
|
import { ensureDir, readFileSafe, writeFile, writeFileIfChanged } from "./utils/file-io.mjs";
|
|
@@ -9,11 +9,12 @@ import { DEFAULT_SERVER_CODEGEN_CONFIG, generateServerTypesCore, generateTypes }
|
|
|
9
9
|
import { validateNoDuplicateTypes } from "./codegen/validation.mjs";
|
|
10
10
|
import { createLogger, createSilentLogger, defaultLogger } from "./utils/logger.mjs";
|
|
11
11
|
import { createCoreConfig, createCoreContext, createScanContext, mergeGraphQLOptions } from "./config.mjs";
|
|
12
|
+
import { loadPackageConfig, resolvePackageFiles } from "./manifest.mjs";
|
|
12
13
|
import { deduplicateFiles, extractPaths, filterByExtension, scanDirectory } from "./scanning/common.mjs";
|
|
13
|
-
import { scanWithAST } from "./scanning/ast-scanner.mjs";
|
|
14
|
+
import { parseSingleFile, scanWithAST } from "./scanning/ast-scanner.mjs";
|
|
14
15
|
import { scanDirectivesCore } from "./scanning/directives.mjs";
|
|
15
16
|
import { scanDocumentsCore } from "./scanning/documents.mjs";
|
|
16
|
-
import { scanResolversCore } from "./scanning/resolvers.mjs";
|
|
17
|
+
import { parseResolverCall, scanResolversCore } from "./scanning/resolvers.mjs";
|
|
17
18
|
import { scanGraphqlCore, scanSchemasCore } from "./scanning/schemas.mjs";
|
|
18
19
|
import { loadFederationSupport, resetFederationCache, warnFederationUnavailable } from "./schema/federation.mjs";
|
|
19
20
|
import { buildGraphQLSchema, createMergedSchema } from "./schema/builder.mjs";
|
|
@@ -23,4 +24,4 @@ import { getImportId, relativeWithDot } from "./utils/imports.mjs";
|
|
|
23
24
|
import { generateOfetchTemplate } from "./utils/ofetch-templates.mjs";
|
|
24
25
|
import { validateExternalServices } from "./validation/external-services.mjs";
|
|
25
26
|
|
|
26
|
-
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,
|
|
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, loadExternalSchema, loadFederationSupport, loadGraphQLDocuments, loadPackageConfig, mergeGraphQLOptions, parseResolverCall, parseSingleFile, pluginContent, readFileSafe, relativeWithDot, resetFederationCache, resolvePackageFiles, scanDirectivesCore, scanDirectory, scanDocumentsCore, scanGraphqlCore, scanResolversCore, scanSchemasCore, scanWithAST, validateExternalServices, validateNoDuplicateTypes, warnFederationUnavailable, writeFile, writeFileIfChanged };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/core/manifest.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Package Config Loader
|
|
4
|
+
* Loads package configuration for extend functionality
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Package config structure (subset of CLIConfig)
|
|
8
|
+
*/
|
|
9
|
+
interface PackageConfig {
|
|
10
|
+
serverDir?: string;
|
|
11
|
+
clientDir?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Resolved package with config and base directory
|
|
15
|
+
*/
|
|
16
|
+
interface ResolvedPackage {
|
|
17
|
+
config: PackageConfig;
|
|
18
|
+
baseDir: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Resolved extend paths
|
|
22
|
+
*/
|
|
23
|
+
interface ResolvedExtend {
|
|
24
|
+
schemas: string[];
|
|
25
|
+
resolvers: string[];
|
|
26
|
+
directives: string[];
|
|
27
|
+
serverDir: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Load config from package
|
|
31
|
+
* Uses c12 for proper config loading with TypeScript support
|
|
32
|
+
*
|
|
33
|
+
* @param source - Package name or explicit path
|
|
34
|
+
* @param rootDir - Root directory for resolution
|
|
35
|
+
* @returns Resolved package with config and base directory, or null if not found
|
|
36
|
+
*/
|
|
37
|
+
declare function loadPackageConfig(source: string, rootDir: string): Promise<ResolvedPackage | null>;
|
|
38
|
+
/**
|
|
39
|
+
* Scan package's serverDir and resolve all GraphQL files
|
|
40
|
+
*
|
|
41
|
+
* @param pkg - Resolved package with config
|
|
42
|
+
* @returns Resolved file paths
|
|
43
|
+
*/
|
|
44
|
+
declare function resolvePackageFiles(pkg: ResolvedPackage): Promise<ResolvedExtend>;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { PackageConfig, ResolvedExtend, ResolvedPackage, loadPackageConfig, resolvePackageFiles };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { DIRECTIVE_EXTENSIONS, GRAPHQL_EXTENSIONS, RESOLVER_EXTENSIONS } from "./constants.mjs";
|
|
2
|
+
import { dirname, resolve } from "pathe";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { loadConfig } from "c12";
|
|
5
|
+
import { resolvePath } from "mlly";
|
|
6
|
+
import { glob } from "tinyglobby";
|
|
7
|
+
|
|
8
|
+
//#region src/core/manifest.ts
|
|
9
|
+
/**
|
|
10
|
+
* Package Config Loader
|
|
11
|
+
* Loads package configuration for extend functionality
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Load config from package
|
|
15
|
+
* Uses c12 for proper config loading with TypeScript support
|
|
16
|
+
*
|
|
17
|
+
* @param source - Package name or explicit path
|
|
18
|
+
* @param rootDir - Root directory for resolution
|
|
19
|
+
* @returns Resolved package with config and base directory, or null if not found
|
|
20
|
+
*/
|
|
21
|
+
async function loadPackageConfig(source, rootDir) {
|
|
22
|
+
try {
|
|
23
|
+
const pkgDir = dirname(await resolvePath(`${source}/package.json`, {
|
|
24
|
+
url: rootDir,
|
|
25
|
+
extensions: [".json"]
|
|
26
|
+
}));
|
|
27
|
+
const { config } = await loadConfig({
|
|
28
|
+
name: "nitro-graphql",
|
|
29
|
+
cwd: pkgDir,
|
|
30
|
+
defaultConfig: { serverDir: "server/graphql" }
|
|
31
|
+
});
|
|
32
|
+
const serverDir = config?.serverDir || "server/graphql";
|
|
33
|
+
if (!existsSync(resolve(pkgDir, serverDir))) return null;
|
|
34
|
+
return {
|
|
35
|
+
config: { serverDir },
|
|
36
|
+
baseDir: pkgDir
|
|
37
|
+
};
|
|
38
|
+
} catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Scan package's serverDir and resolve all GraphQL files
|
|
44
|
+
*
|
|
45
|
+
* @param pkg - Resolved package with config
|
|
46
|
+
* @returns Resolved file paths
|
|
47
|
+
*/
|
|
48
|
+
async function resolvePackageFiles(pkg) {
|
|
49
|
+
const serverDir = resolve(pkg.baseDir, pkg.config.serverDir || "server/graphql");
|
|
50
|
+
const schemaPattern = `**/*{${GRAPHQL_EXTENSIONS.join(",")}}`;
|
|
51
|
+
const resolverPattern = `**/*{${RESOLVER_EXTENSIONS.join(",")}}`;
|
|
52
|
+
const directivePattern = `**/*{${DIRECTIVE_EXTENSIONS.join(",")}}`;
|
|
53
|
+
const [schemas, resolvers, directives] = await Promise.all([
|
|
54
|
+
glob(schemaPattern, {
|
|
55
|
+
cwd: serverDir,
|
|
56
|
+
absolute: true
|
|
57
|
+
}),
|
|
58
|
+
glob(resolverPattern, {
|
|
59
|
+
cwd: serverDir,
|
|
60
|
+
absolute: true
|
|
61
|
+
}),
|
|
62
|
+
glob(directivePattern, {
|
|
63
|
+
cwd: serverDir,
|
|
64
|
+
absolute: true
|
|
65
|
+
})
|
|
66
|
+
]);
|
|
67
|
+
return {
|
|
68
|
+
schemas,
|
|
69
|
+
resolvers,
|
|
70
|
+
directives,
|
|
71
|
+
serverDir
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
export { loadPackageConfig, resolvePackageFiles };
|
|
@@ -19,5 +19,10 @@ interface ASTScanConfig {
|
|
|
19
19
|
* Scan files matching a pattern and parse their exports using AST
|
|
20
20
|
*/
|
|
21
21
|
declare function scanWithAST(ctx: ScanContext, config: ASTScanConfig): Promise<ScanResult<ScannedResolver>>;
|
|
22
|
+
/**
|
|
23
|
+
* Parse a single file and extract exports using AST
|
|
24
|
+
* Used for manifest resolver files
|
|
25
|
+
*/
|
|
26
|
+
declare function parseSingleFile(filePath: string, parseCall: (calleeName: string, exportName: string, filePath: string) => ResolverImport | null): Promise<ScannedResolver | null>;
|
|
22
27
|
//#endregion
|
|
23
|
-
export { ASTScanConfig, scanWithAST };
|
|
28
|
+
export { ASTScanConfig, parseSingleFile, scanWithAST };
|
|
@@ -59,6 +59,25 @@ async function scanWithAST(ctx, config) {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
+
* Parse a single file and extract exports using AST
|
|
63
|
+
* Used for manifest resolver files
|
|
64
|
+
*/
|
|
65
|
+
async function parseSingleFile(filePath, parseCall) {
|
|
66
|
+
try {
|
|
67
|
+
const parsed = parseSync(filePath, await readFile(filePath, "utf-8"));
|
|
68
|
+
if (parsed.errors && parsed.errors.length > 0) return null;
|
|
69
|
+
const result = parseExports(filePath, parsed.program, {
|
|
70
|
+
pattern: "",
|
|
71
|
+
parseCall,
|
|
72
|
+
emitWarnings: false
|
|
73
|
+
});
|
|
74
|
+
if (result.resolver.imports.length > 0) return result.resolver;
|
|
75
|
+
return null;
|
|
76
|
+
} catch {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
62
81
|
* Parse exports from AST program
|
|
63
82
|
*/
|
|
64
83
|
function parseExports(filePath, program, config) {
|
|
@@ -100,4 +119,4 @@ function parseExports(filePath, program, config) {
|
|
|
100
119
|
}
|
|
101
120
|
|
|
102
121
|
//#endregion
|
|
103
|
-
export { scanWithAST };
|
|
122
|
+
export { parseSingleFile, scanWithAST };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ASTScanConfig, scanWithAST } from "./ast-scanner.mjs";
|
|
1
|
+
import { ASTScanConfig, parseSingleFile, scanWithAST } from "./ast-scanner.mjs";
|
|
2
2
|
import { deduplicateFiles, extractPaths, filterByExtension, scanDirectory } from "./common.mjs";
|
|
3
3
|
import { scanDirectivesCore } from "./directives.mjs";
|
|
4
4
|
import { ScanDocumentsOptions, scanDocumentsCore } from "./documents.mjs";
|
|
5
|
-
import { scanResolversCore } from "./resolvers.mjs";
|
|
5
|
+
import { parseResolverCall, scanResolversCore } from "./resolvers.mjs";
|
|
6
6
|
import { scanGraphqlCore, scanSchemasCore } from "./schemas.mjs";
|
|
7
|
-
export { type ASTScanConfig, type ScanDocumentsOptions, deduplicateFiles, extractPaths, filterByExtension, scanDirectivesCore, scanDirectory, scanDocumentsCore, scanGraphqlCore, scanResolversCore, scanSchemasCore, scanWithAST };
|
|
7
|
+
export { type ASTScanConfig, type ScanDocumentsOptions, deduplicateFiles, extractPaths, filterByExtension, parseResolverCall, parseSingleFile, scanDirectivesCore, scanDirectory, scanDocumentsCore, scanGraphqlCore, scanResolversCore, scanSchemasCore, scanWithAST };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { deduplicateFiles, extractPaths, filterByExtension, scanDirectory } from "./common.mjs";
|
|
2
|
-
import { scanWithAST } from "./ast-scanner.mjs";
|
|
2
|
+
import { parseSingleFile, scanWithAST } from "./ast-scanner.mjs";
|
|
3
3
|
import { scanDirectivesCore } from "./directives.mjs";
|
|
4
4
|
import { scanDocumentsCore } from "./documents.mjs";
|
|
5
|
-
import { scanResolversCore } from "./resolvers.mjs";
|
|
5
|
+
import { parseResolverCall, scanResolversCore } from "./resolvers.mjs";
|
|
6
6
|
import { scanGraphqlCore, scanSchemasCore } from "./schemas.mjs";
|
|
7
7
|
|
|
8
|
-
export { deduplicateFiles, extractPaths, filterByExtension, scanDirectivesCore, scanDirectory, scanDocumentsCore, scanGraphqlCore, scanResolversCore, scanSchemasCore, scanWithAST };
|
|
8
|
+
export { deduplicateFiles, extractPaths, filterByExtension, parseResolverCall, parseSingleFile, scanDirectivesCore, scanDirectory, scanDocumentsCore, scanGraphqlCore, scanResolversCore, scanSchemasCore, scanWithAST };
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { ScanContext, ScanResult, ScannedResolver } from "../types/scanning.mjs";
|
|
1
|
+
import { ResolverImport, ScanContext, ScanResult, ScannedResolver } from "../types/scanning.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/core/scanning/resolvers.d.ts
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Parse a define* function call and return the import info
|
|
7
|
+
* Exported for use by manifest loader
|
|
8
|
+
*/
|
|
9
|
+
declare function parseResolverCall(calleeName: string, exportName: string, filePath: string): ResolverImport | null;
|
|
5
10
|
/**
|
|
6
11
|
* Scan for resolver files and parse their exports
|
|
7
12
|
*/
|
|
8
13
|
declare function scanResolversCore(ctx: ScanContext): Promise<ScanResult<ScannedResolver>>;
|
|
9
14
|
//#endregion
|
|
10
|
-
export { scanResolversCore };
|
|
15
|
+
export { parseResolverCall, scanResolversCore };
|
|
@@ -5,6 +5,7 @@ import { hash } from "ohash";
|
|
|
5
5
|
//#region src/core/scanning/resolvers.ts
|
|
6
6
|
/**
|
|
7
7
|
* Parse a define* function call and return the import info
|
|
8
|
+
* Exported for use by manifest loader
|
|
8
9
|
*/
|
|
9
10
|
function parseResolverCall(calleeName, exportName, filePath) {
|
|
10
11
|
const aliasHash = `_${hash(exportName + filePath).replace(/-/g, "").slice(0, 6)}`;
|
|
@@ -55,4 +56,4 @@ function scanResolversCore(ctx) {
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
//#endregion
|
|
58
|
-
export { scanResolversCore };
|
|
59
|
+
export { parseResolverCall, scanResolversCore };
|
|
@@ -72,11 +72,9 @@ interface CoreFederationConfig {
|
|
|
72
72
|
*/
|
|
73
73
|
interface CorePathsConfig {
|
|
74
74
|
/** Server GraphQL directory (default: 'server/graphql') */
|
|
75
|
-
|
|
75
|
+
serverDir?: string;
|
|
76
76
|
/** Client GraphQL directory (default: 'app/graphql' or 'graphql') */
|
|
77
|
-
|
|
78
|
-
/** Build directory (default: '.nitro' or '.nuxt') */
|
|
79
|
-
buildDir?: string;
|
|
77
|
+
clientDir?: string;
|
|
80
78
|
/** Types output directory (default: '{buildDir}/types') */
|
|
81
79
|
typesDir?: string;
|
|
82
80
|
}
|
package/dist/nitro/codegen.mjs
CHANGED
|
@@ -94,7 +94,7 @@ async function generateMainClientTypes(nitro, options = {}) {
|
|
|
94
94
|
writeFile(clientPath, types.types);
|
|
95
95
|
if (!options.silent) logger.success(`Client types: ${clientPath}`);
|
|
96
96
|
}
|
|
97
|
-
const sdkPath = resolveFilePath(sdkConfig.main, sdkConfig.enabled, true, "{
|
|
97
|
+
const sdkPath = resolveFilePath(sdkConfig.main, sdkConfig.enabled, true, "{clientDir}/default/sdk.ts", placeholders);
|
|
98
98
|
if (sdkPath) {
|
|
99
99
|
writeFile(sdkPath, types.sdk);
|
|
100
100
|
if (!options.silent) logger.success(`SDK: ${sdkPath}`);
|
|
@@ -127,7 +127,7 @@ async function generateExternalTypes(nitro, options = {}) {
|
|
|
127
127
|
writeFile(typesPath, types.types);
|
|
128
128
|
if (!options.silent) consola.success(`[${service.name}] Types: ${typesPath}`);
|
|
129
129
|
}
|
|
130
|
-
const sdkPath = resolveFilePath(service.paths?.sdk ?? sdkConfig.external, sdkConfig.enabled, true, "{
|
|
130
|
+
const sdkPath = resolveFilePath(service.paths?.sdk ?? sdkConfig.external, sdkConfig.enabled, true, "{clientDir}/{serviceName}/sdk.ts", placeholders);
|
|
131
131
|
if (sdkPath) {
|
|
132
132
|
writeFile(sdkPath, types.sdk);
|
|
133
133
|
if (!options.silent) consola.success(`[${service.name}] SDK: ${sdkPath}`);
|
package/dist/nitro/config.d.mts
CHANGED
|
@@ -31,9 +31,8 @@ declare const DEFAULT_SDK_CONFIG: {
|
|
|
31
31
|
* These are used as placeholders and resolved based on framework
|
|
32
32
|
*/
|
|
33
33
|
declare const DEFAULT_PATHS_CONFIG: {
|
|
34
|
-
readonly
|
|
35
|
-
readonly
|
|
36
|
-
readonly buildDir: null;
|
|
34
|
+
readonly serverDir: "server/graphql";
|
|
35
|
+
readonly clientDir: null;
|
|
37
36
|
readonly typesDir: null;
|
|
38
37
|
};
|
|
39
38
|
/**
|
package/dist/nitro/config.mjs
CHANGED
|
@@ -36,9 +36,8 @@ const DEFAULT_SDK_CONFIG = {
|
|
|
36
36
|
* These are used as placeholders and resolved based on framework
|
|
37
37
|
*/
|
|
38
38
|
const DEFAULT_PATHS_CONFIG = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
buildDir: null,
|
|
39
|
+
serverDir: "server/graphql",
|
|
40
|
+
clientDir: null,
|
|
42
41
|
typesDir: null
|
|
43
42
|
};
|
|
44
43
|
/**
|
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,
|
|
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";
|
|
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,
|
|
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 };
|
package/dist/nitro/paths.d.mts
CHANGED
|
@@ -12,12 +12,12 @@ interface PathPlaceholders {
|
|
|
12
12
|
rootDir: string;
|
|
13
13
|
framework: 'nuxt' | 'nitro';
|
|
14
14
|
typesDir: string;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
serverDir: string;
|
|
16
|
+
clientDir: string;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Replace placeholders in a path string
|
|
20
|
-
* Supports: {serviceName}, {buildDir}, {rootDir}, {framework}, {typesDir}, {
|
|
20
|
+
* Supports: {serviceName}, {buildDir}, {rootDir}, {framework}, {typesDir}, {serverDir}, {clientDir}
|
|
21
21
|
*/
|
|
22
22
|
declare function replacePlaceholders(path: string, placeholders: PathPlaceholders): string;
|
|
23
23
|
/**
|
package/dist/nitro/paths.mjs
CHANGED
|
@@ -3,10 +3,10 @@ import { isAbsolute, resolve } from "pathe";
|
|
|
3
3
|
//#region src/nitro/paths.ts
|
|
4
4
|
/**
|
|
5
5
|
* Replace placeholders in a path string
|
|
6
|
-
* Supports: {serviceName}, {buildDir}, {rootDir}, {framework}, {typesDir}, {
|
|
6
|
+
* Supports: {serviceName}, {buildDir}, {rootDir}, {framework}, {typesDir}, {serverDir}, {clientDir}
|
|
7
7
|
*/
|
|
8
8
|
function replacePlaceholders(path, placeholders) {
|
|
9
|
-
return path.replace(/\{serviceName\}/g, placeholders.serviceName || "default").replace(/\{buildDir\}/g, placeholders.buildDir).replace(/\{rootDir\}/g, placeholders.rootDir).replace(/\{framework\}/g, placeholders.framework).replace(/\{typesDir\}/g, placeholders.typesDir).replace(/\{
|
|
9
|
+
return path.replace(/\{serviceName\}/g, placeholders.serviceName || "default").replace(/\{buildDir\}/g, placeholders.buildDir).replace(/\{rootDir\}/g, placeholders.rootDir).replace(/\{framework\}/g, placeholders.framework).replace(/\{typesDir\}/g, placeholders.typesDir).replace(/\{serverDir\}/g, placeholders.serverDir).replace(/\{clientDir\}/g, placeholders.clientDir);
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Get default paths based on framework and user configuration
|
|
@@ -15,19 +15,18 @@ function getDefaultPaths(nitro) {
|
|
|
15
15
|
const isNuxt = nitro.options.framework?.name === "nuxt";
|
|
16
16
|
const rootDir = nitro.options.rootDir;
|
|
17
17
|
const buildDir = nitro.options.buildDir;
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const defaultTypesDir = pathsConfig.typesDir || resolve(defaultBuildDir, "types");
|
|
18
|
+
const graphqlConfig = nitro.options.graphql || {};
|
|
19
|
+
const defaultServerDir = graphqlConfig.serverDir || resolve(rootDir, "server", "graphql");
|
|
20
|
+
const defaultClientDir = graphqlConfig.clientDir || resolve(rootDir, isNuxt ? "app/graphql" : "graphql");
|
|
21
|
+
const defaultTypesDir = graphqlConfig.typesDir || resolve(buildDir, "types");
|
|
23
22
|
return {
|
|
24
23
|
serviceName: "default",
|
|
25
|
-
buildDir
|
|
24
|
+
buildDir,
|
|
26
25
|
rootDir,
|
|
27
26
|
framework: isNuxt ? "nuxt" : "nitro",
|
|
28
27
|
typesDir: defaultTypesDir,
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
serverDir: defaultServerDir,
|
|
29
|
+
clientDir: defaultClientDir
|
|
31
30
|
};
|
|
32
31
|
}
|
|
33
32
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as nitro_deps_h35 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_h35.EventHandlerWithFetch<nitro_deps_h35.EventHandlerRequest, Promise<any>>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as nitro_deps_h30 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_h35 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_h30.EventHandlerWithFetch<nitro_deps_h30.EventHandlerRequest, Promise<string | {
|
|
14
14
|
timestamp: string;
|
|
15
15
|
environment: {
|
|
16
16
|
dev: any;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Nitro } from "nitro/types";
|
|
2
|
+
|
|
3
|
+
//#region src/nitro/setup/extend-loader.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Resolve extend directories for file watching
|
|
7
|
+
* Called early in setup (before watcher) to get directories to watch
|
|
8
|
+
*/
|
|
9
|
+
declare function resolveExtendDirs(nitro: Nitro): Promise<string[]>;
|
|
10
|
+
interface ResolveExtendOptions {
|
|
11
|
+
silent?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Resolve extend configuration and add files to scan results
|
|
15
|
+
* Must be called AFTER scanGraphQLFiles to append to results
|
|
16
|
+
*/
|
|
17
|
+
declare function resolveExtendConfig(nitro: Nitro, options?: ResolveExtendOptions): Promise<void>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { resolveExtendConfig, resolveExtendDirs };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { LOG_TAG } from "../../core/constants.mjs";
|
|
2
|
+
import { loadPackageConfig, resolvePackageFiles } from "../../core/manifest.mjs";
|
|
3
|
+
import { parseSingleFile } from "../../core/scanning/ast-scanner.mjs";
|
|
4
|
+
import { parseResolverCall } from "../../core/scanning/resolvers.mjs";
|
|
5
|
+
import consola from "consola";
|
|
6
|
+
import { dirname, resolve } from "pathe";
|
|
7
|
+
|
|
8
|
+
//#region src/nitro/setup/extend-loader.ts
|
|
9
|
+
const logger = consola.withTag(LOG_TAG);
|
|
10
|
+
/**
|
|
11
|
+
* Resolve extend directories for file watching
|
|
12
|
+
* Called early in setup (before watcher) to get directories to watch
|
|
13
|
+
*/
|
|
14
|
+
async function resolveExtendDirs(nitro) {
|
|
15
|
+
const extend = nitro.options.graphql?.extend;
|
|
16
|
+
if (!extend || !Array.isArray(extend) || extend.length === 0) return [];
|
|
17
|
+
const dirs = [];
|
|
18
|
+
for (const source of extend) if (typeof source === "string") {
|
|
19
|
+
const pkg = await loadPackageConfig(source, nitro.options.rootDir);
|
|
20
|
+
if (pkg) {
|
|
21
|
+
const serverDir = resolve(pkg.baseDir, pkg.config.serverDir || "server/graphql");
|
|
22
|
+
dirs.push(serverDir);
|
|
23
|
+
}
|
|
24
|
+
} else if (source && typeof source === "object") {
|
|
25
|
+
const obj = source;
|
|
26
|
+
if (obj.schemas) {
|
|
27
|
+
const schemas = Array.isArray(obj.schemas) ? obj.schemas : [obj.schemas];
|
|
28
|
+
for (const schemaPath of schemas) dirs.push(dirname(resolve(nitro.options.rootDir, schemaPath)));
|
|
29
|
+
}
|
|
30
|
+
if (obj.resolvers) {
|
|
31
|
+
const resolvers = Array.isArray(obj.resolvers) ? obj.resolvers : [obj.resolvers];
|
|
32
|
+
for (const resolverPath of resolvers) dirs.push(dirname(resolve(nitro.options.rootDir, resolverPath)));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return [...new Set(dirs)];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolve extend configuration and add files to scan results
|
|
39
|
+
* Must be called AFTER scanGraphQLFiles to append to results
|
|
40
|
+
*/
|
|
41
|
+
async function resolveExtendConfig(nitro, options = {}) {
|
|
42
|
+
const extend = nitro.options.graphql?.extend;
|
|
43
|
+
if (!extend || !Array.isArray(extend) || extend.length === 0) return;
|
|
44
|
+
let schemasAdded = 0;
|
|
45
|
+
let resolversAdded = 0;
|
|
46
|
+
for (const source of extend) {
|
|
47
|
+
const result = await processExtendSource(source, nitro, options.silent);
|
|
48
|
+
schemasAdded += result.schemas;
|
|
49
|
+
resolversAdded += result.resolvers;
|
|
50
|
+
}
|
|
51
|
+
if (!options.silent && (schemasAdded > 0 || resolversAdded > 0)) logger.info(`Extended with ${schemasAdded} schema(s), ${resolversAdded} resolver file(s)`);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Process a single extend source (package name or explicit config)
|
|
55
|
+
*/
|
|
56
|
+
async function processExtendSource(source, nitro, silent) {
|
|
57
|
+
if (typeof source === "string") return loadFromPackage(source, nitro, silent);
|
|
58
|
+
if (source && typeof source === "object") return processExplicitPaths(source, nitro);
|
|
59
|
+
return {
|
|
60
|
+
schemas: 0,
|
|
61
|
+
resolvers: 0
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Load and scan files from a package's nitro-graphql.config.ts
|
|
66
|
+
*/
|
|
67
|
+
async function loadFromPackage(packageName, nitro, silent) {
|
|
68
|
+
const pkg = await loadPackageConfig(packageName, nitro.options.rootDir);
|
|
69
|
+
if (!pkg) throw new Error(`[nitro-graphql] Config not found for "${packageName}". Create a nitro-graphql.config.ts file in the package root.`);
|
|
70
|
+
const files = await resolvePackageFiles(pkg);
|
|
71
|
+
if (!silent) logger.info(`Loaded config from ${packageName}`);
|
|
72
|
+
return addPackageFiles(files, nitro);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Add files from a resolved package to scan results
|
|
76
|
+
*/
|
|
77
|
+
async function addPackageFiles(files, nitro) {
|
|
78
|
+
let schemasAdded = 0;
|
|
79
|
+
let resolversAdded = 0;
|
|
80
|
+
for (const schemaPath of files.schemas) if (!nitro.scanSchemas.includes(schemaPath)) {
|
|
81
|
+
nitro.scanSchemas.push(schemaPath);
|
|
82
|
+
schemasAdded++;
|
|
83
|
+
}
|
|
84
|
+
for (const resolverPath of files.resolvers) {
|
|
85
|
+
const parsed = await parseSingleFile(resolverPath, parseResolverCall);
|
|
86
|
+
if (parsed?.imports.length) {
|
|
87
|
+
nitro.scanResolvers.push(parsed);
|
|
88
|
+
resolversAdded++;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
schemas: schemasAdded,
|
|
93
|
+
resolvers: resolversAdded
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Process explicit paths (legacy format)
|
|
98
|
+
*/
|
|
99
|
+
async function processExplicitPaths(source, nitro) {
|
|
100
|
+
let schemasAdded = 0;
|
|
101
|
+
let resolversAdded = 0;
|
|
102
|
+
if (source.schemas) {
|
|
103
|
+
const schemas = Array.isArray(source.schemas) ? source.schemas : [source.schemas];
|
|
104
|
+
for (const schemaPath of schemas) {
|
|
105
|
+
const fullPath = resolve(nitro.options.rootDir, schemaPath);
|
|
106
|
+
if (!nitro.scanSchemas.includes(fullPath)) {
|
|
107
|
+
nitro.scanSchemas.push(fullPath);
|
|
108
|
+
schemasAdded++;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (source.resolvers) {
|
|
113
|
+
const resolvers = Array.isArray(source.resolvers) ? source.resolvers : [source.resolvers];
|
|
114
|
+
for (const resolverPath of resolvers) {
|
|
115
|
+
const parsed = await parseSingleFile(resolve(nitro.options.rootDir, resolverPath), parseResolverCall);
|
|
116
|
+
if (parsed?.imports.length) {
|
|
117
|
+
nitro.scanResolvers.push(parsed);
|
|
118
|
+
resolversAdded++;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
schemas: schemasAdded,
|
|
124
|
+
resolvers: resolversAdded
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
//#endregion
|
|
129
|
+
export { resolveExtendConfig, resolveExtendDirs };
|
|
@@ -11,6 +11,6 @@ declare function setupFileWatcher(nitro: Nitro, watchDirs: string[]): FSWatcher;
|
|
|
11
11
|
/**
|
|
12
12
|
* Determine which directories to watch based on framework and configuration
|
|
13
13
|
*/
|
|
14
|
-
declare function getWatchDirectories(nitro: Nitro): string[];
|
|
14
|
+
declare function getWatchDirectories(nitro: Nitro, extendDirs?: string[]): string[];
|
|
15
15
|
//#endregion
|
|
16
16
|
export { getWatchDirectories, setupFileWatcher };
|
|
@@ -3,13 +3,27 @@ import { generateDirectiveSchemas } from "../../core/utils/directive-parser.mjs"
|
|
|
3
3
|
import { NitroAdapter } from "../adapter.mjs";
|
|
4
4
|
import { generateClientTypes, generateServerTypes } from "../codegen.mjs";
|
|
5
5
|
import { DEFAULT_WATCHER_IGNORE_INITIAL, DEFAULT_WATCHER_PERSISTENT } from "../config.mjs";
|
|
6
|
+
import { resolveExtendConfig } from "./extend-loader.mjs";
|
|
6
7
|
import consola from "consola";
|
|
7
|
-
import { join } from "pathe";
|
|
8
|
+
import { join, resolve } from "pathe";
|
|
9
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
8
10
|
import { watch } from "chokidar";
|
|
9
11
|
|
|
10
12
|
//#region src/nitro/setup/file-watcher.ts
|
|
11
13
|
const logger = consola.withTag(LOG_TAG);
|
|
12
14
|
/**
|
|
15
|
+
* Touch config.ts to trigger Rolldown's file watcher
|
|
16
|
+
* This is needed because Rolldown doesn't detect changes to .graphql files in external packages
|
|
17
|
+
*/
|
|
18
|
+
function triggerRolldownRebuild(nitro) {
|
|
19
|
+
const configPath = resolve(nitro.graphql.serverDir, "config.ts");
|
|
20
|
+
if (existsSync(configPath)) try {
|
|
21
|
+
const content = readFileSync(configPath, "utf-8");
|
|
22
|
+
const timestampComment = `// HMR trigger: ${Date.now()}`;
|
|
23
|
+
writeFileSync(configPath, `${content.replace(/\/\/ HMR trigger: \d+\n?$/, "")}\n${timestampComment}\n`);
|
|
24
|
+
} catch {}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
13
27
|
* Setup file watcher for GraphQL files (schemas, resolvers, directives, documents)
|
|
14
28
|
* Watches for changes and triggers type regeneration and dev server reload
|
|
15
29
|
*/
|
|
@@ -20,6 +34,7 @@ function setupFileWatcher(nitro, watchDirs) {
|
|
|
20
34
|
ignored: nitro.options.ignore
|
|
21
35
|
});
|
|
22
36
|
watcher.on("all", async (_, path) => {
|
|
37
|
+
if (path.includes("/sdk.ts") || path.includes("/sdk.js") || path.endsWith("/config.ts")) return;
|
|
23
38
|
const isGraphQLFile = GRAPHQL_EXTENSIONS.some((ext) => path.endsWith(ext));
|
|
24
39
|
const isResolverFile = RESOLVER_EXTENSIONS.some((ext) => path.endsWith(ext));
|
|
25
40
|
const isDirectiveFile = DIRECTIVE_EXTENSIONS.some((ext) => path.endsWith(ext));
|
|
@@ -32,9 +47,11 @@ function setupFileWatcher(nitro, watchDirs) {
|
|
|
32
47
|
if (directivesPath && !schemas.includes(directivesPath)) schemas.push(directivesPath);
|
|
33
48
|
nitro.scanSchemas = schemas;
|
|
34
49
|
nitro.scanResolvers = (await NitroAdapter.scanResolvers(nitro)).items;
|
|
50
|
+
await resolveExtendConfig(nitro, { silent: true });
|
|
35
51
|
logger.success("Types regenerated");
|
|
36
52
|
await generateServerTypes(nitro, { silent: true });
|
|
37
53
|
await generateClientTypes(nitro, { silent: true });
|
|
54
|
+
if (isGraphQLFile) triggerRolldownRebuild(nitro);
|
|
38
55
|
await nitro.hooks.callHook("dev:reload");
|
|
39
56
|
} else {
|
|
40
57
|
logger.success("Types regenerated");
|
|
@@ -46,7 +63,7 @@ function setupFileWatcher(nitro, watchDirs) {
|
|
|
46
63
|
/**
|
|
47
64
|
* Determine which directories to watch based on framework and configuration
|
|
48
65
|
*/
|
|
49
|
-
function getWatchDirectories(nitro) {
|
|
66
|
+
function getWatchDirectories(nitro, extendDirs = []) {
|
|
50
67
|
const watchDirs = [];
|
|
51
68
|
switch (nitro.options.framework.name) {
|
|
52
69
|
case "nuxt": {
|
|
@@ -65,6 +82,7 @@ function getWatchDirectories(nitro) {
|
|
|
65
82
|
watchDirs.push(nitro.graphql.clientDir);
|
|
66
83
|
watchDirs.push(nitro.graphql.serverDir);
|
|
67
84
|
}
|
|
85
|
+
for (const dir of extendDirs) if (!watchDirs.includes(dir)) watchDirs.push(dir);
|
|
68
86
|
if (nitro.options.graphql?.externalServices?.length) {
|
|
69
87
|
for (const service of nitro.options.graphql.externalServices) if (service.documents?.length) for (const pattern of service.documents) {
|
|
70
88
|
if (!pattern) continue;
|
package/dist/nitro/setup.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { getDefaultPaths } from "./paths.mjs";
|
|
|
6
6
|
import { generateClientTypes, generateServerTypes } from "./codegen.mjs";
|
|
7
7
|
import { DEFAULT_RUNTIME_CONFIG, DEFAULT_TYPESCRIPT_STRICT, DEFAULT_TYPES_CONFIG } from "./config.mjs";
|
|
8
8
|
import { rollupConfig } from "./rollup.mjs";
|
|
9
|
+
import { resolveExtendConfig, resolveExtendDirs } from "./setup/extend-loader.mjs";
|
|
9
10
|
import { getWatchDirectories, setupFileWatcher } from "./setup/file-watcher.mjs";
|
|
10
11
|
import { logStartupInfo, resolveSecurityConfig } from "./setup/logging.mjs";
|
|
11
12
|
import { setupRollupChunking, setupRollupExternals } from "./setup/rollup-integration.mjs";
|
|
@@ -45,8 +46,9 @@ async function setupNitroGraphQL(nitro) {
|
|
|
45
46
|
setupRollupChunking(nitro);
|
|
46
47
|
}
|
|
47
48
|
initializeRuntimeConfig(nitro);
|
|
48
|
-
setupFileWatching(nitro, serverEnabled);
|
|
49
|
+
setupFileWatching(nitro, serverEnabled, await resolveExtendDirs(nitro));
|
|
49
50
|
await scanGraphQLFiles(nitro, serverEnabled);
|
|
51
|
+
await resolveExtendConfig(nitro);
|
|
50
52
|
if (serverEnabled) setupDevHooks(nitro);
|
|
51
53
|
if (serverEnabled) await rollupConfig(nitro);
|
|
52
54
|
await generateTypes(nitro, serverEnabled);
|
|
@@ -67,8 +69,8 @@ function initializeConfiguration(nitro, serverEnabled) {
|
|
|
67
69
|
nitro.graphql ||= {
|
|
68
70
|
buildDir: "",
|
|
69
71
|
watchDirs: [],
|
|
70
|
-
clientDir: defaultPaths.
|
|
71
|
-
serverDir: defaultPaths.
|
|
72
|
+
clientDir: defaultPaths.clientDir,
|
|
73
|
+
serverDir: defaultPaths.serverDir,
|
|
72
74
|
dir: {
|
|
73
75
|
build: relative(nitro.options.rootDir, nitro.options.buildDir),
|
|
74
76
|
client: "graphql",
|
|
@@ -126,8 +128,8 @@ function initializeRuntimeConfig(nitro) {
|
|
|
126
128
|
/**
|
|
127
129
|
* Setup file watching for development mode
|
|
128
130
|
*/
|
|
129
|
-
function setupFileWatching(nitro, serverEnabled) {
|
|
130
|
-
const watchDirs = serverEnabled ? getWatchDirectories(nitro) : [nitro.graphql.clientDir].filter(Boolean);
|
|
131
|
+
function setupFileWatching(nitro, serverEnabled, extendDirs = []) {
|
|
132
|
+
const watchDirs = serverEnabled ? getWatchDirectories(nitro, extendDirs) : [nitro.graphql.clientDir].filter(Boolean);
|
|
131
133
|
nitro.graphql.watchDirs = watchDirs;
|
|
132
134
|
const watcher = setupFileWatcher(nitro, watchDirs);
|
|
133
135
|
nitro.hooks.hook("close", () => {
|
|
@@ -158,6 +160,7 @@ function setupDevHooks(nitro) {
|
|
|
158
160
|
let hasShownInitialLogs = false;
|
|
159
161
|
nitro.hooks.hook("dev:start", async () => {
|
|
160
162
|
await scanAllGraphQLFiles(nitro);
|
|
163
|
+
await resolveExtendConfig(nitro);
|
|
161
164
|
if (nitro.options.dev && !hasShownInitialLogs) {
|
|
162
165
|
hasShownInitialLogs = true;
|
|
163
166
|
logResolverDiagnostics(nitro);
|
package/dist/nitro/types.d.mts
CHANGED
|
@@ -151,6 +151,12 @@ declare module 'nitro/types' {
|
|
|
151
151
|
client: string;
|
|
152
152
|
server: string;
|
|
153
153
|
};
|
|
154
|
+
/** Resolved extend paths from manifests (populated during setup) */
|
|
155
|
+
resolvedExtend?: {
|
|
156
|
+
schemas: string[];
|
|
157
|
+
resolvers: string[];
|
|
158
|
+
directives: string[];
|
|
159
|
+
};
|
|
154
160
|
};
|
|
155
161
|
}
|
|
156
162
|
}
|
|
@@ -207,7 +213,7 @@ interface ExternalGraphQLService {
|
|
|
207
213
|
/**
|
|
208
214
|
* Optional: Service-specific path overrides
|
|
209
215
|
* These paths take precedence over global config (sdk, types, clientUtils)
|
|
210
|
-
* Supports placeholders: {serviceName}, {buildDir}, {rootDir}, {framework}, {typesDir}, {
|
|
216
|
+
* Supports placeholders: {serviceName}, {buildDir}, {rootDir}, {framework}, {typesDir}, {clientDir}
|
|
211
217
|
*/
|
|
212
218
|
paths?: ExternalServicePaths;
|
|
213
219
|
}
|
|
@@ -254,20 +260,6 @@ interface TypesConfig {
|
|
|
254
260
|
/** .nitro/types/nitro-graphql-client-{serviceName}.d.ts - External service types */
|
|
255
261
|
external?: FileGenerationConfig;
|
|
256
262
|
}
|
|
257
|
-
/**
|
|
258
|
-
* Global path overrides
|
|
259
|
-
* Set base directories for file generation
|
|
260
|
-
*/
|
|
261
|
-
interface PathsConfig {
|
|
262
|
-
/** Server GraphQL directory (default: 'server/graphql') */
|
|
263
|
-
serverGraphql?: string;
|
|
264
|
-
/** Client GraphQL directory (default: 'app/graphql' for Nuxt, 'graphql' for Nitro) */
|
|
265
|
-
clientGraphql?: string;
|
|
266
|
-
/** Build directory (default: '.nitro' or '.nuxt') */
|
|
267
|
-
buildDir?: string;
|
|
268
|
-
/** Types directory (default: '{buildDir}/types') */
|
|
269
|
-
typesDir?: string;
|
|
270
|
-
}
|
|
271
263
|
/**
|
|
272
264
|
* Security configuration for production environments
|
|
273
265
|
* All options auto-detect based on NODE_ENV when not explicitly set
|
|
@@ -326,8 +318,12 @@ interface NitroGraphQLOptions {
|
|
|
326
318
|
externalServices?: ExternalGraphQLService[];
|
|
327
319
|
/** Apollo Federation configuration */
|
|
328
320
|
federation?: FederationConfig;
|
|
329
|
-
/** Server GraphQL directory path */
|
|
321
|
+
/** Server GraphQL directory path (default: 'server/graphql') */
|
|
330
322
|
serverDir?: string;
|
|
323
|
+
/** Client GraphQL directory path (default: 'app/graphql' for Nuxt, 'graphql' for Nitro) */
|
|
324
|
+
clientDir?: string;
|
|
325
|
+
/** Types directory path (default: '{buildDir}/types') */
|
|
326
|
+
typesDir?: string;
|
|
331
327
|
/** Layer directories (populated by Nuxt module) */
|
|
332
328
|
layerDirectories?: string[];
|
|
333
329
|
layerServerDirs?: string[];
|
|
@@ -342,11 +338,6 @@ interface NitroGraphQLOptions {
|
|
|
342
338
|
* Set to false to disable all type generation
|
|
343
339
|
*/
|
|
344
340
|
types?: false | TypesConfig;
|
|
345
|
-
/**
|
|
346
|
-
* Global path overrides
|
|
347
|
-
* Customize base directories for file generation
|
|
348
|
-
*/
|
|
349
|
-
paths?: PathsConfig;
|
|
350
341
|
/**
|
|
351
342
|
* Security configuration for production environments
|
|
352
343
|
* Auto-detects NODE_ENV and applies secure defaults in production
|
|
@@ -367,12 +358,17 @@ interface NitroGraphQLOptions {
|
|
|
367
358
|
}
|
|
368
359
|
/**
|
|
369
360
|
* Extend source - package path or detailed config
|
|
370
|
-
* - string:
|
|
371
|
-
* - object: explicit
|
|
361
|
+
* - string: package name, requires graphql-manifest.json in package root
|
|
362
|
+
* - object with manifest: explicit manifest path
|
|
363
|
+
* - object with resolvers/schemas: explicit paths (legacy)
|
|
372
364
|
*/
|
|
373
365
|
type ExtendSource = string | {
|
|
366
|
+
/** Explicit manifest path */
|
|
367
|
+
manifest?: string;
|
|
368
|
+
/** Explicit resolver paths (legacy, prefer manifest) */
|
|
374
369
|
resolvers?: string | string[];
|
|
370
|
+
/** Explicit schema paths (legacy, prefer manifest) */
|
|
375
371
|
schemas?: string | string[];
|
|
376
372
|
};
|
|
377
373
|
//#endregion
|
|
378
|
-
export { CodegenClientConfig, CodegenServerConfig, DefineDirectiveConfig, DefineServerConfig, DirectiveArgument, DirectiveDefinition, ExtendSource, ExternalGraphQLService, ExternalServicePaths, FederationConfig, FileGenerationConfig, Flatten, GenImport, GenericSdkConfig, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType, NitroGraphQLOptions,
|
|
374
|
+
export { CodegenClientConfig, CodegenServerConfig, DefineDirectiveConfig, DefineServerConfig, DirectiveArgument, DirectiveDefinition, ExtendSource, ExternalGraphQLService, ExternalServicePaths, FederationConfig, FileGenerationConfig, Flatten, GenImport, GenericSdkConfig, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType, NitroGraphQLOptions, SdkConfig, SecurityConfig, StandardSchemaV1, TypesConfig };
|
|
@@ -1,41 +1,8 @@
|
|
|
1
1
|
import { getImportId } from "../../core/utils/imports.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { resolve } from "pathe";
|
|
3
3
|
import { genImport } from "knitwork";
|
|
4
4
|
|
|
5
5
|
//#region src/nitro/virtual/generators.ts
|
|
6
|
-
function normalizeExtendConfig(extend) {
|
|
7
|
-
if (!extend || !Array.isArray(extend) || extend.length === 0) return null;
|
|
8
|
-
const resolvers = [];
|
|
9
|
-
const schemas = [];
|
|
10
|
-
for (const source of extend) if (typeof source === "string") {
|
|
11
|
-
resolvers.push(`${source}/resolvers`);
|
|
12
|
-
schemas.push(`${source}/schema`);
|
|
13
|
-
} else if (source && typeof source === "object") {
|
|
14
|
-
const obj = source;
|
|
15
|
-
if (obj.resolvers) {
|
|
16
|
-
const r = Array.isArray(obj.resolvers) ? obj.resolvers : [obj.resolvers];
|
|
17
|
-
resolvers.push(...r);
|
|
18
|
-
}
|
|
19
|
-
if (obj.schemas) {
|
|
20
|
-
const s = Array.isArray(obj.schemas) ? obj.schemas : [obj.schemas];
|
|
21
|
-
schemas.push(...s);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
if (resolvers.length === 0 && schemas.length === 0) return null;
|
|
25
|
-
return {
|
|
26
|
-
resolvers,
|
|
27
|
-
schemas
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Resolve extend path to absolute path
|
|
32
|
-
* Supports: relative paths, absolute paths, package names
|
|
33
|
-
*/
|
|
34
|
-
function resolveExtendPath(nitro, inputPath) {
|
|
35
|
-
if (inputPath.startsWith("@") || !inputPath.startsWith(".") && !inputPath.startsWith("/")) return inputPath;
|
|
36
|
-
if (isAbsolute(inputPath)) return inputPath;
|
|
37
|
-
return resolve(nitro.options.rootDir, inputPath);
|
|
38
|
-
}
|
|
39
6
|
function generateImportModule(items, exportName, wrapperKey) {
|
|
40
7
|
if (!items.length) return `export const ${exportName} = []`;
|
|
41
8
|
const imports = items.flatMap(({ specifier, imports: list, options }) => list?.length ? [genImport(specifier, list, options)] : []);
|
|
@@ -54,34 +21,6 @@ function safeGenerateModuleCode(nitro, moduleName) {
|
|
|
54
21
|
const serverSchemas = {
|
|
55
22
|
id: "#nitro-graphql/server-schemas",
|
|
56
23
|
getCode: (nitro) => {
|
|
57
|
-
const ext = normalizeExtendConfig(nitro.options.graphql?.extend);
|
|
58
|
-
const skipLocalScan = nitro.options.graphql?.skipLocalScan === true;
|
|
59
|
-
if (ext && ext.schemas.length > 0) {
|
|
60
|
-
const schemaPaths = ext.schemas.map((p) => resolveExtendPath(nitro, p));
|
|
61
|
-
const scannedSchemas = [...nitro.scanSchemas, ...nitro.options.graphql?.typedefs ?? []];
|
|
62
|
-
if (!skipLocalScan && scannedSchemas.length > 0) {
|
|
63
|
-
const extImports = schemaPaths.map((p, i) => `import { schemaString as extSchema${i} } from '${p}'`);
|
|
64
|
-
const scannedImports = scannedSchemas.map((s) => `import ${getImportId(s)} from '${s}';`);
|
|
65
|
-
const extDefs = schemaPaths.map((_, i) => `{ def: extSchema${i} }`);
|
|
66
|
-
const scannedDefs = scannedSchemas.map((s) => `{ def: ${getImportId(s)} }`);
|
|
67
|
-
return `${extImports.join("\n")}
|
|
68
|
-
${scannedImports.join("\n")}
|
|
69
|
-
|
|
70
|
-
export const schemas = [
|
|
71
|
-
${[...extDefs, ...scannedDefs].join(",\n")}
|
|
72
|
-
]`;
|
|
73
|
-
}
|
|
74
|
-
if (schemaPaths.length === 1) return `import { schemaString, typeDefs } from '${schemaPaths[0]}'
|
|
75
|
-
export { schemaString, typeDefs }
|
|
76
|
-
export const schemas = [{ def: schemaString }]`;
|
|
77
|
-
const imports = schemaPaths.map((p, i) => `import { schemaString as schema${i} } from '${p}'`);
|
|
78
|
-
const schemaVars = schemaPaths.map((_, i) => `schema${i}`);
|
|
79
|
-
const mergeCode = `export const schemaString = [${schemaVars.join(", ")}].join('\\n\\n')
|
|
80
|
-
import { parse } from 'graphql'
|
|
81
|
-
export const typeDefs = parse(schemaString)
|
|
82
|
-
export const schemas = [${schemaVars.map((v) => `{ def: ${v} }`).join(", ")}]`;
|
|
83
|
-
return `${imports.join("\n")}\n\n${mergeCode}`;
|
|
84
|
-
}
|
|
85
24
|
const schemas = [...nitro.scanSchemas, ...nitro.options.graphql?.typedefs ?? []];
|
|
86
25
|
if (!schemas.length) {
|
|
87
26
|
if (nitro.options.dev) nitro.logger.warn("[nitro-graphql] No schemas found. Virtual module will export empty array.");
|
|
@@ -95,25 +34,6 @@ export const schemas = [${schemaVars.map((v) => `{ def: ${v} }`).join(", ")}]`;
|
|
|
95
34
|
const serverResolvers = {
|
|
96
35
|
id: "#nitro-graphql/server-resolvers",
|
|
97
36
|
getCode: (nitro) => {
|
|
98
|
-
const ext = normalizeExtendConfig(nitro.options.graphql?.extend);
|
|
99
|
-
const skipLocalScan = nitro.options.graphql?.skipLocalScan === true;
|
|
100
|
-
if (ext && ext.resolvers.length > 0) {
|
|
101
|
-
const resolverPaths = ext.resolvers.map((p) => resolveExtendPath(nitro, p));
|
|
102
|
-
const imports$1 = resolverPaths.map((p, i) => `import { resolvers as resolvers${i} } from '${p}'`);
|
|
103
|
-
if (!skipLocalScan && nitro.scanResolvers.length > 0) {
|
|
104
|
-
const scannedCode = generateImportModule(nitro.scanResolvers, "scannedResolvers", "resolver");
|
|
105
|
-
const spreadAll$1 = [...resolverPaths.map((_, i) => `...resolvers${i}`), "...scannedResolvers"];
|
|
106
|
-
return `${imports$1.join("\n")}
|
|
107
|
-
${scannedCode}
|
|
108
|
-
|
|
109
|
-
export const resolvers = [${spreadAll$1.join(", ")}]`;
|
|
110
|
-
}
|
|
111
|
-
if (resolverPaths.length === 1) return `export { resolvers } from '${resolverPaths[0]}'`;
|
|
112
|
-
const spreadAll = resolverPaths.map((_, i) => `...resolvers${i}`);
|
|
113
|
-
return `${imports$1.join("\n")}
|
|
114
|
-
|
|
115
|
-
export const resolvers = [${spreadAll.join(", ")}]`;
|
|
116
|
-
}
|
|
117
37
|
const imports = [...nitro.scanResolvers];
|
|
118
38
|
if (!imports.length) {
|
|
119
39
|
if (nitro.options.dev) nitro.logger.warn("[nitro-graphql] No resolvers found. Virtual module will export empty array.");
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitro-graphql",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.41",
|
|
5
5
|
"description": "GraphQL integration for Nitro",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -52,6 +52,10 @@
|
|
|
52
52
|
"types": "./dist/cli/index.d.mts",
|
|
53
53
|
"import": "./dist/cli/index.mjs"
|
|
54
54
|
},
|
|
55
|
+
"./config": {
|
|
56
|
+
"types": "./dist/config.d.mts",
|
|
57
|
+
"import": "./dist/config.mjs"
|
|
58
|
+
},
|
|
55
59
|
"./define": {
|
|
56
60
|
"types": "./dist/define.d.mts",
|
|
57
61
|
"import": "./dist/define.mjs"
|
|
@@ -100,6 +104,7 @@
|
|
|
100
104
|
"@graphql-tools/schema": "^10.0.30",
|
|
101
105
|
"@graphql-tools/url-loader": "^9.0.5",
|
|
102
106
|
"@graphql-tools/utils": "^10.11.0",
|
|
107
|
+
"c12": "^3.3.3",
|
|
103
108
|
"chokidar": "^5.0.0",
|
|
104
109
|
"citty": "^0.1.6",
|
|
105
110
|
"consola": "^3.4.2",
|
|
@@ -108,6 +113,7 @@
|
|
|
108
113
|
"graphql-config": "^5.1.5",
|
|
109
114
|
"graphql-scalars": "^1.25.0",
|
|
110
115
|
"knitwork": "^1.3.0",
|
|
116
|
+
"mlly": "^1.8.0",
|
|
111
117
|
"ohash": "^2.0.11",
|
|
112
118
|
"oxc-parser": "^0.106.0",
|
|
113
119
|
"pathe": "^2.0.3",
|