nitro-graphql 2.0.0-beta.36 → 2.0.0-beta.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/generate.d.mts +26 -0
- package/dist/cli/commands/generate.mjs +196 -0
- package/dist/cli/commands/index.d.mts +4 -0
- package/dist/cli/commands/index.mjs +5 -0
- package/dist/cli/commands/init.d.mts +12 -0
- package/dist/cli/commands/init.mjs +100 -0
- package/dist/cli/commands/validate.d.mts +10 -0
- package/dist/cli/commands/validate.mjs +69 -0
- package/dist/cli/config.d.mts +75 -0
- package/dist/cli/config.mjs +20 -0
- package/dist/cli/index.d.mts +24 -0
- package/dist/cli/index.mjs +219 -0
- package/dist/core/codegen/client.d.mts +23 -0
- package/dist/core/codegen/client.mjs +150 -0
- package/dist/core/codegen/document-loader.d.mts +10 -0
- package/dist/core/codegen/document-loader.mjs +18 -0
- package/dist/core/codegen/index.d.mts +8 -0
- package/dist/core/codegen/index.mjs +9 -0
- package/dist/{utils/codegen-plugin.d.mts → core/codegen/plugin.d.mts} +2 -2
- package/dist/{utils/codegen-plugin.mjs → core/codegen/plugin.mjs} +1 -1
- package/dist/core/codegen/runtime.d.mts +20 -0
- package/dist/core/codegen/runtime.mjs +60 -0
- package/dist/core/codegen/schema-loader.d.mts +28 -0
- package/dist/core/codegen/schema-loader.mjs +128 -0
- package/dist/core/codegen/server.d.mts +28 -0
- package/dist/core/codegen/server.mjs +143 -0
- package/dist/{codegen → core/codegen}/validation.d.mts +1 -1
- package/dist/{codegen → core/codegen}/validation.mjs +1 -1
- package/dist/core/config.d.mts +50 -0
- package/dist/core/config.mjs +82 -0
- package/dist/core/constants.d.mts +188 -0
- package/dist/core/constants.mjs +210 -0
- package/dist/core/index.d.mts +32 -0
- package/dist/core/index.mjs +26 -0
- package/dist/core/scanning/ast-scanner.d.mts +23 -0
- package/dist/core/scanning/ast-scanner.mjs +103 -0
- package/dist/core/scanning/common.d.mts +37 -0
- package/dist/core/scanning/common.mjs +60 -0
- package/dist/core/scanning/directives.d.mts +10 -0
- package/dist/core/scanning/directives.mjs +29 -0
- package/dist/core/scanning/documents.d.mts +21 -0
- package/dist/core/scanning/documents.mjs +43 -0
- package/dist/core/scanning/index.d.mts +7 -0
- package/dist/core/scanning/index.mjs +8 -0
- package/dist/core/scanning/resolvers.d.mts +10 -0
- package/dist/core/scanning/resolvers.mjs +58 -0
- package/dist/core/scanning/schemas.d.mts +14 -0
- package/dist/core/scanning/schemas.mjs +64 -0
- package/dist/{utils/schema-builder.d.mts → core/schema/builder.d.mts} +7 -2
- package/dist/{utils/schema-builder.mjs → core/schema/builder.mjs} +22 -3
- package/dist/{utils → core/schema}/federation.d.mts +10 -5
- package/dist/{utils → core/schema}/federation.mjs +1 -1
- package/dist/core/schema/index.d.mts +3 -0
- package/dist/core/schema/index.mjs +4 -0
- package/dist/core/types/adapter.d.mts +58 -0
- package/dist/core/types/codegen.d.mts +133 -0
- package/dist/core/types/config.d.mts +212 -0
- package/dist/{types → core/types}/define.d.mts +3 -7
- package/dist/core/types/index.d.mts +5 -0
- package/dist/core/types/scanning.d.mts +69 -0
- package/dist/core/types/scanning.mjs +1 -0
- package/dist/{utils → core/utils}/directive-parser.d.mts +21 -5
- package/dist/{utils → core/utils}/directive-parser.mjs +25 -36
- package/dist/{utils → core/utils}/errors.d.mts +8 -4
- package/dist/{utils → core/utils}/errors.mjs +8 -4
- package/dist/core/utils/file-io.d.mts +24 -0
- package/dist/core/utils/file-io.mjs +47 -0
- package/dist/{utils → core/utils}/imports.d.mts +1 -1
- package/dist/{utils → core/utils}/imports.mjs +1 -1
- package/dist/core/utils/index.d.mts +7 -0
- package/dist/core/utils/index.mjs +8 -0
- package/dist/core/utils/logger.d.mts +19 -0
- package/dist/core/utils/logger.mjs +38 -0
- package/dist/{utils → core/utils}/ofetch-templates.d.mts +1 -1
- package/dist/{utils → core/utils}/ofetch-templates.mjs +1 -1
- package/dist/core/validation/external-services.d.mts +11 -0
- package/dist/{utils/validation.mjs → core/validation/external-services.mjs} +3 -3
- package/dist/core/validation/index.d.mts +2 -0
- package/dist/core/validation/index.mjs +3 -0
- package/dist/define.d.mts +1 -3
- package/dist/index.d.mts +6 -43
- package/dist/index.mjs +5 -62
- package/dist/nitro/adapter.d.mts +30 -0
- package/dist/nitro/adapter.mjs +97 -0
- package/dist/{utils → nitro}/apollo.d.mts +1 -1
- package/dist/{utils → nitro}/apollo.mjs +1 -1
- package/dist/nitro/codegen.d.mts +19 -0
- package/dist/nitro/codegen.mjs +141 -0
- package/dist/nitro/config.d.mts +52 -0
- package/dist/nitro/config.mjs +58 -0
- package/dist/nitro/index.d.mts +46 -0
- package/dist/nitro/index.mjs +65 -0
- package/dist/{utils/path-resolver.d.mts → nitro/paths.d.mts} +3 -19
- package/dist/{utils/path-resolver.mjs → nitro/paths.mjs} +2 -36
- package/dist/{rollup.d.mts → nitro/rollup.d.mts} +1 -1
- package/dist/{rollup.mjs → nitro/rollup.mjs} +11 -23
- package/dist/{routes → nitro/routes}/apollo-server.d.mts +1 -1
- package/dist/nitro/routes/apollo-server.mjs +71 -0
- package/dist/{routes → nitro/routes}/debug-template.d.mts +1 -1
- package/dist/{routes → nitro/routes}/debug-template.mjs +1 -1
- package/dist/{routes → nitro/routes}/debug.d.mts +10 -16
- package/dist/{routes → nitro/routes}/debug.mjs +2 -2
- package/dist/nitro/routes/graphql-yoga.d.mts +6 -0
- package/dist/{routes → nitro/routes}/graphql-yoga.mjs +21 -10
- package/dist/nitro/routes/health.d.mts +10 -0
- package/dist/{routes → nitro/routes}/health.mjs +1 -1
- package/dist/nitro/setup/file-watcher.d.mts +16 -0
- package/dist/{setup → nitro/setup}/file-watcher.mjs +14 -18
- package/dist/nitro/setup/logging.d.mts +17 -0
- package/dist/nitro/setup/logging.mjs +66 -0
- package/dist/nitro/setup/rollup-integration.d.mts +16 -0
- package/dist/{setup → nitro/setup}/rollup-integration.mjs +2 -2
- package/dist/nitro/setup/routes.d.mts +10 -0
- package/dist/nitro/setup/routes.mjs +35 -0
- package/dist/nitro/setup/ts-config.d.mts +11 -0
- package/dist/{setup → nitro/setup}/ts-config.mjs +3 -3
- package/dist/{setup.d.mts → nitro/setup.d.mts} +3 -2
- package/dist/{setup.mjs → nitro/setup.mjs} +73 -62
- package/dist/nitro/types.d.mts +378 -0
- package/dist/nitro/types.mjs +1 -0
- package/dist/nitro/virtual/generators.d.mts +31 -0
- package/dist/nitro/virtual/generators.mjs +193 -0
- package/dist/nitro/virtual/stubs.d.mts +20 -0
- package/dist/nitro/virtual/stubs.mjs +31 -0
- package/dist/{ecosystem/nuxt.d.mts → nuxt.d.mts} +1 -1
- package/dist/{ecosystem/nuxt.mjs → nuxt.mjs} +2 -2
- package/dist/{graphql/server.d.mts → stubs/index.d.mts} +5 -1
- package/dist/stubs/index.mjs +1 -0
- package/package.json +45 -43
- package/dist/codegen/client-types.d.mts +0 -13
- package/dist/codegen/client-types.mjs +0 -131
- package/dist/codegen/external-types.d.mts +0 -12
- package/dist/codegen/external-types.mjs +0 -88
- package/dist/codegen/index.d.mts +0 -18
- package/dist/codegen/index.mjs +0 -24
- package/dist/codegen/server-types.d.mts +0 -13
- package/dist/codegen/server-types.mjs +0 -64
- package/dist/config/defaults.mjs +0 -36
- package/dist/constants/scalars.mjs +0 -27
- package/dist/constants.mjs +0 -106
- package/dist/graphql/index.d.mts +0 -5
- package/dist/routes/apollo-server.mjs +0 -45
- package/dist/routes/graphql-yoga.d.mts +0 -6
- package/dist/routes/health.d.mts +0 -10
- package/dist/setup/graphql-scanner.mjs +0 -25
- package/dist/setup/scaffold-generator.mjs +0 -109
- package/dist/types/index.d.mts +0 -246
- package/dist/types/standard-schema.d.mts +0 -59
- package/dist/utils/client-codegen.d.mts +0 -41
- package/dist/utils/client-codegen.mjs +0 -267
- package/dist/utils/file-generator.d.mts +0 -37
- package/dist/utils/file-generator.mjs +0 -72
- package/dist/utils/file-writer.d.mts +0 -35
- package/dist/utils/file-writer.mjs +0 -32
- package/dist/utils/index.d.mts +0 -13
- package/dist/utils/index.mjs +0 -13
- package/dist/utils/layers.d.mts +0 -22
- package/dist/utils/layers.mjs +0 -28
- package/dist/utils/scanning/common.d.mts +0 -23
- package/dist/utils/scanning/common.mjs +0 -39
- package/dist/utils/scanning/directives.d.mts +0 -11
- package/dist/utils/scanning/directives.mjs +0 -43
- package/dist/utils/scanning/documents.d.mts +0 -15
- package/dist/utils/scanning/documents.mjs +0 -46
- package/dist/utils/scanning/index.d.mts +0 -6
- package/dist/utils/scanning/index.mjs +0 -7
- package/dist/utils/scanning/resolvers.d.mts +0 -11
- package/dist/utils/scanning/resolvers.mjs +0 -100
- package/dist/utils/scanning/schemas.d.mts +0 -15
- package/dist/utils/scanning/schemas.mjs +0 -29
- package/dist/utils/server-codegen.d.mts +0 -7
- package/dist/utils/server-codegen.mjs +0 -113
- package/dist/utils/type-generation.d.mts +0 -6
- package/dist/utils/type-generation.mjs +0 -7
- package/dist/utils/validation.d.mts +0 -11
- package/dist/virtual/debug-info.d.mts +0 -9
- package/dist/virtual/debug-info.mjs +0 -26
- package/dist/virtual/generators/config.d.mts +0 -22
- package/dist/virtual/generators/config.mjs +0 -36
- package/dist/virtual/generators/debug.d.mts +0 -14
- package/dist/virtual/generators/debug.mjs +0 -53
- package/dist/virtual/generators/directives.d.mts +0 -14
- package/dist/virtual/generators/directives.mjs +0 -52
- package/dist/virtual/generators/index.d.mts +0 -6
- package/dist/virtual/generators/index.mjs +0 -7
- package/dist/virtual/generators/resolvers.d.mts +0 -14
- package/dist/virtual/generators/resolvers.mjs +0 -55
- package/dist/virtual/generators/schemas.d.mts +0 -14
- package/dist/virtual/generators/schemas.mjs +0 -43
- package/dist/virtual/graphql-config.d.mts +0 -9
- package/dist/virtual/graphql-config.mjs +0 -10
- package/dist/virtual/module-config.d.mts +0 -9
- package/dist/virtual/module-config.mjs +0 -10
- package/dist/virtual/server-directives.d.mts +0 -11
- package/dist/virtual/server-directives.mjs +0 -10
- package/dist/virtual/server-resolvers.d.mts +0 -11
- package/dist/virtual/server-resolvers.mjs +0 -10
- package/dist/virtual/server-schemas.d.mts +0 -11
- package/dist/virtual/server-schemas.mjs +0 -10
- /package/dist/{graphql/index.mjs → core/types/adapter.mjs} +0 -0
- /package/dist/{graphql/server.mjs → core/types/codegen.mjs} +0 -0
- /package/dist/{types/define.mjs → core/types/config.mjs} +0 -0
- /package/dist/{types/index.mjs → core/types/define.mjs} +0 -0
- /package/dist/{types/standard-schema.mjs → core/types/index.mjs} +0 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { CurrencyResolver, DateTimeISOResolver, DateTimeResolver, JSONObjectResolver, JSONResolver, NonEmptyStringResolver, UUIDResolver } from "graphql-scalars";
|
|
2
|
+
|
|
3
|
+
//#region src/core/constants.ts
|
|
4
|
+
/**
|
|
5
|
+
* Constants and magic strings used throughout nitro-graphql core
|
|
6
|
+
* Centralizing these values prevents typos and makes refactoring easier
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Default scalar type mappings for GraphQL codegen
|
|
10
|
+
* These scalars are commonly used and have proper TypeScript type mappings
|
|
11
|
+
*/
|
|
12
|
+
const DEFAULT_GRAPHQL_SCALARS = {
|
|
13
|
+
DateTime: DateTimeResolver.extensions.codegenScalarType,
|
|
14
|
+
DateTimeISO: DateTimeISOResolver.extensions.codegenScalarType,
|
|
15
|
+
UUID: UUIDResolver.extensions.codegenScalarType,
|
|
16
|
+
JSON: JSONResolver.extensions.codegenScalarType,
|
|
17
|
+
JSONObject: JSONObjectResolver.extensions.codegenScalarType,
|
|
18
|
+
NonEmptyString: NonEmptyStringResolver.extensions.codegenScalarType,
|
|
19
|
+
Currency: CurrencyResolver.extensions.codegenScalarType,
|
|
20
|
+
File: {
|
|
21
|
+
input: "File",
|
|
22
|
+
output: "File"
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* GraphQL schema file extensions
|
|
27
|
+
*/
|
|
28
|
+
const GRAPHQL_EXTENSIONS = [".graphql", ".gql"];
|
|
29
|
+
/**
|
|
30
|
+
* Resolver file extensions
|
|
31
|
+
*/
|
|
32
|
+
const RESOLVER_EXTENSIONS = [".resolver.ts", ".resolver.js"];
|
|
33
|
+
/**
|
|
34
|
+
* Directive file extensions
|
|
35
|
+
*/
|
|
36
|
+
const DIRECTIVE_EXTENSIONS = [".directive.ts", ".directive.js"];
|
|
37
|
+
/**
|
|
38
|
+
* Combined pattern for glob scanning
|
|
39
|
+
*/
|
|
40
|
+
const GLOB_SCAN_PATTERN = "**/*.{graphql,gql,js,mjs,cjs,ts,mts,cts,tsx,jsx}";
|
|
41
|
+
/**
|
|
42
|
+
* GraphQL file pattern for glob
|
|
43
|
+
*/
|
|
44
|
+
const GRAPHQL_GLOB_PATTERN = "**/*.graphql";
|
|
45
|
+
/**
|
|
46
|
+
* Resolver file pattern for glob
|
|
47
|
+
*/
|
|
48
|
+
const RESOLVER_GLOB_PATTERN = "**/*.resolver.{ts,js}";
|
|
49
|
+
/**
|
|
50
|
+
* Directive file pattern for glob
|
|
51
|
+
*/
|
|
52
|
+
const DIRECTIVE_GLOB_PATTERN = "**/*.directive.{ts,js}";
|
|
53
|
+
/**
|
|
54
|
+
* Framework names
|
|
55
|
+
*/
|
|
56
|
+
const FRAMEWORK_NUXT = "nuxt";
|
|
57
|
+
const FRAMEWORK_NITRO = "nitro";
|
|
58
|
+
const FRAMEWORK_STANDALONE = "standalone";
|
|
59
|
+
/**
|
|
60
|
+
* GraphQL server framework identifiers
|
|
61
|
+
*/
|
|
62
|
+
const GRAPHQL_FRAMEWORK_YOGA = "graphql-yoga";
|
|
63
|
+
const GRAPHQL_FRAMEWORK_APOLLO = "apollo-server";
|
|
64
|
+
/**
|
|
65
|
+
* Default directory names for GraphQL files
|
|
66
|
+
*/
|
|
67
|
+
const DIR_SERVER_GRAPHQL = "server/graphql";
|
|
68
|
+
const DIR_ROUTES_GRAPHQL = "routes/graphql";
|
|
69
|
+
const DIR_APP_GRAPHQL = "app/graphql";
|
|
70
|
+
const DIR_CLIENT_GRAPHQL = "graphql";
|
|
71
|
+
const DIR_EXTERNAL = "external";
|
|
72
|
+
/**
|
|
73
|
+
* Windows-compatible server GraphQL directory
|
|
74
|
+
*/
|
|
75
|
+
const DIR_SERVER_GRAPHQL_WIN = "server\\graphql";
|
|
76
|
+
/**
|
|
77
|
+
* Build directory names
|
|
78
|
+
*/
|
|
79
|
+
const DIR_BUILD_NITRO = ".nitro";
|
|
80
|
+
const DIR_BUILD_NUXT = ".nuxt";
|
|
81
|
+
/**
|
|
82
|
+
* Default GraphQL endpoint paths
|
|
83
|
+
*/
|
|
84
|
+
const ENDPOINT_GRAPHQL = "/api/graphql";
|
|
85
|
+
const ENDPOINT_HEALTH = "/api/graphql/health";
|
|
86
|
+
const ENDPOINT_DEBUG = "/_nitro/graphql/debug";
|
|
87
|
+
/**
|
|
88
|
+
* Configuration and scaffold file names
|
|
89
|
+
*/
|
|
90
|
+
const FILE_GRAPHQL_CONFIG = "graphql.config.ts";
|
|
91
|
+
const FILE_SCHEMA_GRAPHQL = "schema.graphql";
|
|
92
|
+
const FILE_SCHEMA_TS = "schema.ts";
|
|
93
|
+
const FILE_CONFIG_TS = "config.ts";
|
|
94
|
+
const FILE_CONTEXT_DTS = "context.d.ts";
|
|
95
|
+
const FILE_CONTEXT_TS = "context.ts";
|
|
96
|
+
const FILE_INDEX_TS = "index.ts";
|
|
97
|
+
const FILE_OFETCH_TS = "ofetch.ts";
|
|
98
|
+
const FILE_SDK_TS = "sdk.ts";
|
|
99
|
+
const FILE_DIRECTIVES_GRAPHQL = "_directives.graphql";
|
|
100
|
+
/**
|
|
101
|
+
* Generated type definition file names
|
|
102
|
+
*/
|
|
103
|
+
const FILE_SERVER_TYPES = "nitro-graphql-server.d.ts";
|
|
104
|
+
const FILE_CLIENT_TYPES = "nitro-graphql-client.d.ts";
|
|
105
|
+
const FILE_GRAPHQL_DTS = "graphql.d.ts";
|
|
106
|
+
/**
|
|
107
|
+
* Generated type file name patterns with placeholders
|
|
108
|
+
*/
|
|
109
|
+
const PATTERN_CLIENT_EXTERNAL_TYPES = "nitro-graphql-client-{serviceName}.d.ts";
|
|
110
|
+
/**
|
|
111
|
+
* Rollup/Rolldown chunk output paths
|
|
112
|
+
*/
|
|
113
|
+
const CHUNK_PATH_GRAPHQL = "chunks/graphql/[name].mjs";
|
|
114
|
+
const CHUNK_PATH_UNKNOWN = "chunks/_/[name].mjs";
|
|
115
|
+
/**
|
|
116
|
+
* Default chunk names
|
|
117
|
+
*/
|
|
118
|
+
const CHUNK_NAME_SCHEMAS = "schemas";
|
|
119
|
+
const CHUNK_NAME_RESOLVERS = "resolvers";
|
|
120
|
+
/**
|
|
121
|
+
* Valid define function names for resolver exports
|
|
122
|
+
*/
|
|
123
|
+
const DEFINE_FUNCTIONS = [
|
|
124
|
+
"defineResolver",
|
|
125
|
+
"defineQuery",
|
|
126
|
+
"defineMutation",
|
|
127
|
+
"defineField",
|
|
128
|
+
"defineSubscription",
|
|
129
|
+
"defineDirective"
|
|
130
|
+
];
|
|
131
|
+
const DEFINE_RESOLVER = "defineResolver";
|
|
132
|
+
const DEFINE_QUERY = "defineQuery";
|
|
133
|
+
const DEFINE_MUTATION = "defineMutation";
|
|
134
|
+
const DEFINE_FIELD = "defineField";
|
|
135
|
+
const DEFINE_SUBSCRIPTION = "defineSubscription";
|
|
136
|
+
const DEFINE_DIRECTIVE = "defineDirective";
|
|
137
|
+
const DEFINE_GRAPHQL_CONFIG = "defineGraphQLConfig";
|
|
138
|
+
const DEFINE_SCHEMA = "defineSchema";
|
|
139
|
+
/**
|
|
140
|
+
* Built-in GraphQL scalar types (should not be flagged as duplicates)
|
|
141
|
+
*/
|
|
142
|
+
const BUILTIN_SCALARS = [
|
|
143
|
+
"String",
|
|
144
|
+
"Int",
|
|
145
|
+
"Float",
|
|
146
|
+
"Boolean",
|
|
147
|
+
"ID",
|
|
148
|
+
"DateTime",
|
|
149
|
+
"JSON"
|
|
150
|
+
];
|
|
151
|
+
/**
|
|
152
|
+
* Codegen parser dependencies (always external)
|
|
153
|
+
*/
|
|
154
|
+
const CODEGEN_EXTERNALS = ["oxc-parser", "@oxc-parser"];
|
|
155
|
+
/**
|
|
156
|
+
* Apollo Federation dependencies (external when federation disabled)
|
|
157
|
+
*/
|
|
158
|
+
const FEDERATION_EXTERNALS = [
|
|
159
|
+
"@apollo/subgraph",
|
|
160
|
+
"@apollo/federation-internals",
|
|
161
|
+
"@apollo/cache-control-types"
|
|
162
|
+
];
|
|
163
|
+
/**
|
|
164
|
+
* Supported HTTP methods for GraphQL endpoints
|
|
165
|
+
*/
|
|
166
|
+
const GRAPHQL_HTTP_METHODS = [
|
|
167
|
+
"GET",
|
|
168
|
+
"POST",
|
|
169
|
+
"OPTIONS"
|
|
170
|
+
];
|
|
171
|
+
/**
|
|
172
|
+
* Default paths for type generation (relative to buildDir)
|
|
173
|
+
*/
|
|
174
|
+
const DEFAULT_SERVER_TYPES_PATH = ".graphql/nitro-graphql-server.d.ts";
|
|
175
|
+
const DEFAULT_CLIENT_TYPES_PATH = ".graphql/nitro-graphql-client.d.ts";
|
|
176
|
+
/**
|
|
177
|
+
* Valid resolver export types detected from AST parsing
|
|
178
|
+
*/
|
|
179
|
+
const RESOLVER_TYPE_QUERY = "query";
|
|
180
|
+
const RESOLVER_TYPE_MUTATION = "mutation";
|
|
181
|
+
const RESOLVER_TYPE_RESOLVER = "resolver";
|
|
182
|
+
const RESOLVER_TYPE_TYPE = "type";
|
|
183
|
+
const RESOLVER_TYPE_SUBSCRIPTION = "subscription";
|
|
184
|
+
const RESOLVER_TYPE_DIRECTIVE = "directive";
|
|
185
|
+
/**
|
|
186
|
+
* Placeholder strings used in path resolution
|
|
187
|
+
*/
|
|
188
|
+
const PLACEHOLDER_SERVICE_NAME = "{serviceName}";
|
|
189
|
+
const PLACEHOLDER_BUILD_DIR = "{buildDir}";
|
|
190
|
+
const PLACEHOLDER_ROOT_DIR = "{rootDir}";
|
|
191
|
+
const PLACEHOLDER_FRAMEWORK = "{framework}";
|
|
192
|
+
const PLACEHOLDER_TYPES_DIR = "{typesDir}";
|
|
193
|
+
const PLACEHOLDER_SERVER_GRAPHQL = "{serverGraphql}";
|
|
194
|
+
const PLACEHOLDER_CLIENT_GRAPHQL = "{clientGraphql}";
|
|
195
|
+
/**
|
|
196
|
+
* Logger tag for nitro-graphql module
|
|
197
|
+
*/
|
|
198
|
+
const LOG_TAG = "nitro-graphql";
|
|
199
|
+
/**
|
|
200
|
+
* HTTP status codes for error handling
|
|
201
|
+
*/
|
|
202
|
+
const HTTP_STATUS_BAD_REQUEST = 400;
|
|
203
|
+
const HTTP_STATUS_INTERNAL_ERROR = 500;
|
|
204
|
+
/**
|
|
205
|
+
* Default service directory name for main service
|
|
206
|
+
*/
|
|
207
|
+
const SERVICE_DEFAULT = "default";
|
|
208
|
+
|
|
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, PLACEHOLDER_CLIENT_GRAPHQL, PLACEHOLDER_FRAMEWORK, PLACEHOLDER_ROOT_DIR, PLACEHOLDER_SERVER_GRAPHQL, 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 };
|
|
@@ -0,0 +1,32 @@
|
|
|
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_GRAPHQL, PLACEHOLDER_FRAMEWORK, PLACEHOLDER_ROOT_DIR, PLACEHOLDER_SERVER_GRAPHQL, 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
|
+
import { ClientCodegenConfig, ClientCodegenInput, ClientCodegenResult, ExternalServiceCodegenConfig, ScalarType, SchemaLoadOptions, SdkCodegenConfig, ServerCodegenConfig, ServerCodegenInput, ServerCodegenResult } from "./types/codegen.mjs";
|
|
3
|
+
import { CoreClientUtilsConfig, CoreCodegenConfig, CoreConfig, CoreContext, CoreExternalService, CoreFederationConfig, CoreGraphQLOptions, CoreLogger, CorePathsConfig, CoreScaffoldConfig, CoreSdkConfig, CoreSecurityConfig, CoreTypesConfig } from "./types/config.mjs";
|
|
4
|
+
import { DefineDirectiveConfig, DirectiveArgument, DirectiveDefinition, Flatten, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType } from "./types/define.mjs";
|
|
5
|
+
import { ResolverImport, ScanContext, ScanResult, ScannedFile, ScannedResolver } from "./types/scanning.mjs";
|
|
6
|
+
import "./types/index.mjs";
|
|
7
|
+
import { loadGraphQLDocuments } from "./codegen/document-loader.mjs";
|
|
8
|
+
import { GraphQLLoadSchemaOptions, GraphQLTypeDefPointer, downloadAndSaveSchema, graphQLLoadSchemaSync, loadExternalSchema } from "./codegen/schema-loader.mjs";
|
|
9
|
+
import { DEFAULT_CLIENT_CODEGEN_CONFIG, generateClientTypesCore, generateExternalClientTypesCore } from "./codegen/client.mjs";
|
|
10
|
+
import { GENERATED_FILE_HEADER, pluginContent } from "./codegen/plugin.mjs";
|
|
11
|
+
import { generateResolverModule, generateRuntimeIndex, generateSchemaModule } from "./codegen/runtime.mjs";
|
|
12
|
+
import { DEFAULT_SERVER_CODEGEN_CONFIG, generateServerTypesCore, generateTypes } from "./codegen/server.mjs";
|
|
13
|
+
import { validateNoDuplicateTypes } from "./codegen/validation.mjs";
|
|
14
|
+
import "./codegen/index.mjs";
|
|
15
|
+
import { CreateCoreConfigOptions, createCoreConfig, createCoreContext, createScanContext, mergeGraphQLOptions } from "./config.mjs";
|
|
16
|
+
import { ASTScanConfig, scanWithAST } from "./scanning/ast-scanner.mjs";
|
|
17
|
+
import { deduplicateFiles, extractPaths, filterByExtension, scanDirectory } from "./scanning/common.mjs";
|
|
18
|
+
import { scanDirectivesCore } from "./scanning/directives.mjs";
|
|
19
|
+
import { ScanDocumentsOptions, scanDocumentsCore } from "./scanning/documents.mjs";
|
|
20
|
+
import { scanResolversCore } from "./scanning/resolvers.mjs";
|
|
21
|
+
import { scanGraphqlCore, scanSchemasCore } from "./scanning/schemas.mjs";
|
|
22
|
+
import { CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema } from "./schema/builder.mjs";
|
|
23
|
+
import { loadFederationSupport, resetFederationCache, warnFederationUnavailable } from "./schema/federation.mjs";
|
|
24
|
+
import "./schema/index.mjs";
|
|
25
|
+
import { DirectiveFileRef, DirectiveParser, ParsedDirective, directiveParser, generateDirectiveSchema, generateDirectiveSchemas } from "./utils/directive-parser.mjs";
|
|
26
|
+
import { MaskErrorOptions, createDefaultMaskError } from "./utils/errors.mjs";
|
|
27
|
+
import { ensureDir, readFileSafe, writeFile, writeFileIfChanged } from "./utils/file-io.mjs";
|
|
28
|
+
import { getImportId, relativeWithDot } from "./utils/imports.mjs";
|
|
29
|
+
import { createLogger, createSilentLogger, defaultLogger } from "./utils/logger.mjs";
|
|
30
|
+
import { OfetchTemplateOptions, generateOfetchTemplate } from "./utils/ofetch-templates.mjs";
|
|
31
|
+
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, PLACEHOLDER_CLIENT_GRAPHQL, PLACEHOLDER_FRAMEWORK, PLACEHOLDER_ROOT_DIR, PLACEHOLDER_SERVER_GRAPHQL, PLACEHOLDER_SERVICE_NAME, PLACEHOLDER_TYPES_DIR, ParsedDirective, RESOLVER_EXTENSIONS, RESOLVER_GLOB_PATTERN, RESOLVER_TYPE_DIRECTIVE, RESOLVER_TYPE_MUTATION, RESOLVER_TYPE_QUERY, RESOLVER_TYPE_RESOLVER, RESOLVER_TYPE_SUBSCRIPTION, RESOLVER_TYPE_TYPE, 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, mergeGraphQLOptions, pluginContent, readFileSafe, relativeWithDot, resetFederationCache, scanDirectivesCore, scanDirectory, scanDocumentsCore, scanGraphqlCore, scanResolversCore, scanSchemasCore, scanWithAST, validateExternalServices, validateNoDuplicateTypes, warnFederationUnavailable, writeFile, writeFileIfChanged };
|
|
@@ -0,0 +1,26 @@
|
|
|
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_GRAPHQL, PLACEHOLDER_FRAMEWORK, PLACEHOLDER_ROOT_DIR, PLACEHOLDER_SERVER_GRAPHQL, 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
|
+
import { GENERATED_FILE_HEADER, pluginContent } from "./codegen/plugin.mjs";
|
|
3
|
+
import { loadGraphQLDocuments } from "./codegen/document-loader.mjs";
|
|
4
|
+
import { ensureDir, readFileSafe, writeFile, writeFileIfChanged } from "./utils/file-io.mjs";
|
|
5
|
+
import { downloadAndSaveSchema, graphQLLoadSchemaSync, loadExternalSchema } from "./codegen/schema-loader.mjs";
|
|
6
|
+
import { DEFAULT_CLIENT_CODEGEN_CONFIG, generateClientTypesCore, generateExternalClientTypesCore } from "./codegen/client.mjs";
|
|
7
|
+
import { generateResolverModule, generateRuntimeIndex, generateSchemaModule } from "./codegen/runtime.mjs";
|
|
8
|
+
import { DEFAULT_SERVER_CODEGEN_CONFIG, generateServerTypesCore, generateTypes } from "./codegen/server.mjs";
|
|
9
|
+
import { validateNoDuplicateTypes } from "./codegen/validation.mjs";
|
|
10
|
+
import { createLogger, createSilentLogger, defaultLogger } from "./utils/logger.mjs";
|
|
11
|
+
import { createCoreConfig, createCoreContext, createScanContext, mergeGraphQLOptions } from "./config.mjs";
|
|
12
|
+
import { deduplicateFiles, extractPaths, filterByExtension, scanDirectory } from "./scanning/common.mjs";
|
|
13
|
+
import { scanWithAST } from "./scanning/ast-scanner.mjs";
|
|
14
|
+
import { scanDirectivesCore } from "./scanning/directives.mjs";
|
|
15
|
+
import { scanDocumentsCore } from "./scanning/documents.mjs";
|
|
16
|
+
import { scanResolversCore } from "./scanning/resolvers.mjs";
|
|
17
|
+
import { scanGraphqlCore, scanSchemasCore } from "./scanning/schemas.mjs";
|
|
18
|
+
import { loadFederationSupport, resetFederationCache, warnFederationUnavailable } from "./schema/federation.mjs";
|
|
19
|
+
import { buildGraphQLSchema, createMergedSchema } from "./schema/builder.mjs";
|
|
20
|
+
import { DirectiveParser, directiveParser, generateDirectiveSchema, generateDirectiveSchemas } from "./utils/directive-parser.mjs";
|
|
21
|
+
import { createDefaultMaskError } from "./utils/errors.mjs";
|
|
22
|
+
import { getImportId, relativeWithDot } from "./utils/imports.mjs";
|
|
23
|
+
import { generateOfetchTemplate } from "./utils/ofetch-templates.mjs";
|
|
24
|
+
import { validateExternalServices } from "./validation/external-services.mjs";
|
|
25
|
+
|
|
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, PLACEHOLDER_CLIENT_GRAPHQL, PLACEHOLDER_FRAMEWORK, PLACEHOLDER_ROOT_DIR, PLACEHOLDER_SERVER_GRAPHQL, 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, mergeGraphQLOptions, pluginContent, readFileSafe, relativeWithDot, resetFederationCache, scanDirectivesCore, scanDirectory, scanDocumentsCore, scanGraphqlCore, scanResolversCore, scanSchemasCore, scanWithAST, validateExternalServices, validateNoDuplicateTypes, warnFederationUnavailable, writeFile, writeFileIfChanged };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ResolverImport, ScanContext, ScanResult, ScannedResolver } from "../types/scanning.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/scanning/ast-scanner.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for AST-based scanning
|
|
7
|
+
*/
|
|
8
|
+
interface ASTScanConfig {
|
|
9
|
+
/** Glob pattern for files to scan */
|
|
10
|
+
pattern: string;
|
|
11
|
+
/** Parse a function call and return import info, or null if not a valid export */
|
|
12
|
+
parseCall: (calleeName: string, exportName: string, filePath: string) => ResolverImport | null;
|
|
13
|
+
/** Whether to emit warnings for common issues (default: true for resolvers) */
|
|
14
|
+
emitWarnings?: boolean;
|
|
15
|
+
/** Valid function names for warning messages */
|
|
16
|
+
validFunctions?: readonly string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Scan files matching a pattern and parse their exports using AST
|
|
20
|
+
*/
|
|
21
|
+
declare function scanWithAST(ctx: ScanContext, config: ASTScanConfig): Promise<ScanResult<ScannedResolver>>;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { ASTScanConfig, scanWithAST };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { scanWithLayers } from "./common.mjs";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { basename, relative } from "pathe";
|
|
4
|
+
import { parseSync } from "oxc-parser";
|
|
5
|
+
|
|
6
|
+
//#region src/core/scanning/ast-scanner.ts
|
|
7
|
+
/**
|
|
8
|
+
* Scan files matching a pattern and parse their exports using AST
|
|
9
|
+
*/
|
|
10
|
+
async function scanWithAST(ctx, config) {
|
|
11
|
+
const warnings = [];
|
|
12
|
+
const errors = [];
|
|
13
|
+
try {
|
|
14
|
+
const serverDirRelative = relative(ctx.rootDir, ctx.serverDir);
|
|
15
|
+
const files = await scanWithLayers(ctx, {
|
|
16
|
+
mainDir: ctx.rootDir,
|
|
17
|
+
mainSubDir: serverDirRelative,
|
|
18
|
+
layerDirs: ctx.layerServerDirs,
|
|
19
|
+
layerSubDir: "graphql",
|
|
20
|
+
pattern: config.pattern
|
|
21
|
+
});
|
|
22
|
+
const results = [];
|
|
23
|
+
for (const file of files) try {
|
|
24
|
+
const fileContent = await readFile(file.fullPath, "utf-8");
|
|
25
|
+
const parsed = parseSync(file.fullPath, fileContent);
|
|
26
|
+
if (parsed.errors && parsed.errors.length > 0) {
|
|
27
|
+
if (ctx.isDev) {
|
|
28
|
+
const fileName = basename(file.fullPath);
|
|
29
|
+
const firstError = parsed.errors[0];
|
|
30
|
+
const location = firstError?.labels?.[0];
|
|
31
|
+
const lineInfo = location ? `:${location.start}` : "";
|
|
32
|
+
const message = firstError?.message.split(",")[0] || "Syntax error";
|
|
33
|
+
errors.push(`${fileName}${lineInfo} - ${message}`);
|
|
34
|
+
}
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const result = parseExports(file.fullPath, parsed.program, config);
|
|
38
|
+
if (ctx.isDev && config.emitWarnings && result.warnings.length > 0) {
|
|
39
|
+
const relPath = relative(ctx.rootDir, file.fullPath);
|
|
40
|
+
for (const warning of result.warnings) warnings.push(`${relPath}: ${warning}`);
|
|
41
|
+
}
|
|
42
|
+
if (result.resolver.imports.length > 0) results.push(result.resolver);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
const relPath = relative(ctx.rootDir, file.fullPath);
|
|
45
|
+
errors.push(`Failed to parse file ${relPath}: ${error}`);
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
items: results,
|
|
49
|
+
warnings,
|
|
50
|
+
errors
|
|
51
|
+
};
|
|
52
|
+
} catch (error) {
|
|
53
|
+
errors.push(`Scanning error: ${error}`);
|
|
54
|
+
return {
|
|
55
|
+
items: [],
|
|
56
|
+
warnings,
|
|
57
|
+
errors
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Parse exports from AST program
|
|
63
|
+
*/
|
|
64
|
+
function parseExports(filePath, program, config) {
|
|
65
|
+
const warnings = [];
|
|
66
|
+
const resolver = {
|
|
67
|
+
specifier: filePath,
|
|
68
|
+
imports: []
|
|
69
|
+
};
|
|
70
|
+
let hasDefaultExport = false;
|
|
71
|
+
let hasNamedExport = false;
|
|
72
|
+
const namedExports = [];
|
|
73
|
+
for (const node of program.body) {
|
|
74
|
+
if (node.type === "ExportDefaultDeclaration") hasDefaultExport = true;
|
|
75
|
+
if (node.type === "ExportNamedDeclaration" && node.declaration && node.declaration.type === "VariableDeclaration") {
|
|
76
|
+
for (const decl of node.declaration.declarations) if (decl.type === "VariableDeclarator" && decl.init && decl.id.type === "Identifier") {
|
|
77
|
+
hasNamedExport = true;
|
|
78
|
+
namedExports.push(decl.id.name);
|
|
79
|
+
if (decl.init && decl.init.type === "CallExpression") {
|
|
80
|
+
if (decl.init.callee.type === "Identifier") {
|
|
81
|
+
const imp = config.parseCall(decl.init.callee.name, decl.id.name, filePath);
|
|
82
|
+
if (imp) resolver.imports.push(imp);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (config.emitWarnings) {
|
|
89
|
+
if (hasDefaultExport && !hasNamedExport) warnings.push("Using default export instead of named export. Must use named exports like \"export const myResolver = defineQuery(...)\". Default exports are not detected.");
|
|
90
|
+
if (resolver.imports.length === 0 && hasNamedExport) {
|
|
91
|
+
const validFunctions = config.validFunctions?.join(", ") || "define* functions";
|
|
92
|
+
warnings.push(`File has named exports [${namedExports.join(", ")}] but none use the required define functions (${validFunctions}). Exports will not be registered.`);
|
|
93
|
+
}
|
|
94
|
+
if (!hasDefaultExport && !hasNamedExport) warnings.push("No exports found. Files must export using define* functions.");
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
resolver,
|
|
98
|
+
warnings
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//#endregion
|
|
103
|
+
export { scanWithAST };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ScanContext, ScannedFile } from "../types/scanning.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/scanning/common.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Scan a directory for files matching a glob pattern
|
|
7
|
+
*/
|
|
8
|
+
declare function scanDirectory(ctx: ScanContext, baseDir: string, subDir: string, globPattern?: string): Promise<ScannedFile[]>;
|
|
9
|
+
/**
|
|
10
|
+
* Deduplicate files by fullPath
|
|
11
|
+
*/
|
|
12
|
+
declare function deduplicateFiles<T extends {
|
|
13
|
+
fullPath: string;
|
|
14
|
+
}>(files: T[]): T[];
|
|
15
|
+
/**
|
|
16
|
+
* Filter files by extension
|
|
17
|
+
*/
|
|
18
|
+
declare function filterByExtension<T extends {
|
|
19
|
+
fullPath: string;
|
|
20
|
+
}>(files: T[], extensions: readonly string[]): T[];
|
|
21
|
+
/**
|
|
22
|
+
* Extract file paths from scanned files
|
|
23
|
+
*/
|
|
24
|
+
declare function extractPaths(files: ScannedFile[]): string[];
|
|
25
|
+
/**
|
|
26
|
+
* Scan directory with layer support
|
|
27
|
+
* Encapsulates the common pattern of scanning main directory + layer directories
|
|
28
|
+
*/
|
|
29
|
+
declare function scanWithLayers(ctx: ScanContext, options: {
|
|
30
|
+
mainDir: string;
|
|
31
|
+
mainSubDir: string;
|
|
32
|
+
layerDirs: string[] | undefined;
|
|
33
|
+
layerSubDir: string;
|
|
34
|
+
pattern: string;
|
|
35
|
+
}): Promise<ScannedFile[]>;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { deduplicateFiles, extractPaths, filterByExtension, scanDirectory, scanWithLayers };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { GLOB_SCAN_PATTERN } from "../constants.mjs";
|
|
2
|
+
import { join, relative } from "pathe";
|
|
3
|
+
import { glob } from "tinyglobby";
|
|
4
|
+
|
|
5
|
+
//#region src/core/scanning/common.ts
|
|
6
|
+
/**
|
|
7
|
+
* Scan a directory for files matching a glob pattern
|
|
8
|
+
*/
|
|
9
|
+
async function scanDirectory(ctx, baseDir, subDir, globPattern = GLOB_SCAN_PATTERN) {
|
|
10
|
+
return (await glob(join(subDir, globPattern), {
|
|
11
|
+
cwd: baseDir,
|
|
12
|
+
dot: true,
|
|
13
|
+
ignore: ctx.ignorePatterns,
|
|
14
|
+
absolute: true
|
|
15
|
+
}).catch((error) => {
|
|
16
|
+
if (error?.code === "ENOTDIR") {
|
|
17
|
+
ctx.logger.warn(`Ignoring \`${join(baseDir, subDir)}\`. It must be a directory.`);
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
throw error;
|
|
21
|
+
})).map((fullPath) => ({
|
|
22
|
+
fullPath,
|
|
23
|
+
path: relative(join(baseDir, subDir), fullPath)
|
|
24
|
+
})).sort((a, b) => a.path.localeCompare(b.path));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Deduplicate files by fullPath
|
|
28
|
+
*/
|
|
29
|
+
function deduplicateFiles(files) {
|
|
30
|
+
const seenPaths = /* @__PURE__ */ new Set();
|
|
31
|
+
return files.filter((file) => {
|
|
32
|
+
if (seenPaths.has(file.fullPath)) return false;
|
|
33
|
+
seenPaths.add(file.fullPath);
|
|
34
|
+
return true;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Filter files by extension
|
|
39
|
+
*/
|
|
40
|
+
function filterByExtension(files, extensions) {
|
|
41
|
+
return files.filter((file) => extensions.some((ext) => file.fullPath.endsWith(ext)));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Extract file paths from scanned files
|
|
45
|
+
*/
|
|
46
|
+
function extractPaths(files) {
|
|
47
|
+
return files.map((f) => f.fullPath);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Scan directory with layer support
|
|
51
|
+
* Encapsulates the common pattern of scanning main directory + layer directories
|
|
52
|
+
*/
|
|
53
|
+
async function scanWithLayers(ctx, options) {
|
|
54
|
+
const mainFiles = await scanDirectory(ctx, options.mainDir, options.mainSubDir, options.pattern);
|
|
55
|
+
const layerFiles = await Promise.all((options.layerDirs || []).map((layerDir) => scanDirectory(ctx, layerDir, options.layerSubDir, options.pattern))).then((r) => r.flat());
|
|
56
|
+
return deduplicateFiles([...mainFiles, ...layerFiles]);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { deduplicateFiles, extractPaths, filterByExtension, scanDirectory, scanWithLayers };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ScanContext, ScanResult, ScannedResolver } from "../types/scanning.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/scanning/directives.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Scan for directive files (.directive.ts/.js)
|
|
7
|
+
*/
|
|
8
|
+
declare function scanDirectivesCore(ctx: ScanContext): Promise<ScanResult<ScannedResolver>>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { scanDirectivesCore };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DIRECTIVE_GLOB_PATTERN } from "../constants.mjs";
|
|
2
|
+
import { scanWithAST } from "./ast-scanner.mjs";
|
|
3
|
+
import { hash } from "ohash";
|
|
4
|
+
|
|
5
|
+
//#region src/core/scanning/directives.ts
|
|
6
|
+
/**
|
|
7
|
+
* Parse a defineDirective call and return the import info
|
|
8
|
+
*/
|
|
9
|
+
function parseDirectiveCall(calleeName, exportName, filePath) {
|
|
10
|
+
if (calleeName !== "defineDirective") return null;
|
|
11
|
+
return {
|
|
12
|
+
name: exportName,
|
|
13
|
+
type: "directive",
|
|
14
|
+
as: `_${hash(exportName + filePath).replace(/-/g, "").slice(0, 6)}`
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Scan for directive files (.directive.ts/.js)
|
|
19
|
+
*/
|
|
20
|
+
function scanDirectivesCore(ctx) {
|
|
21
|
+
return scanWithAST(ctx, {
|
|
22
|
+
pattern: DIRECTIVE_GLOB_PATTERN,
|
|
23
|
+
parseCall: parseDirectiveCall,
|
|
24
|
+
emitWarnings: false
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { scanDirectivesCore };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CoreExternalService } from "../types/config.mjs";
|
|
2
|
+
import { ScanContext, ScanResult } from "../types/scanning.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/core/scanning/documents.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Options for scanning documents
|
|
8
|
+
*/
|
|
9
|
+
interface ScanDocumentsOptions {
|
|
10
|
+
/** External services to exclude from main scan */
|
|
11
|
+
externalServices?: CoreExternalService[];
|
|
12
|
+
/** Client directory relative path */
|
|
13
|
+
clientDirRelative?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Scan for GraphQL client documents (.graphql) in client directory
|
|
17
|
+
* Excludes files from external service directories
|
|
18
|
+
*/
|
|
19
|
+
declare function scanDocumentsCore(ctx: ScanContext, options?: ScanDocumentsOptions): Promise<ScanResult<string>>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { ScanDocumentsOptions, scanDocumentsCore };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { GRAPHQL_GLOB_PATTERN } from "../constants.mjs";
|
|
2
|
+
import { scanWithLayers } from "./common.mjs";
|
|
3
|
+
import { relative } from "pathe";
|
|
4
|
+
|
|
5
|
+
//#region src/core/scanning/documents.ts
|
|
6
|
+
/**
|
|
7
|
+
* Scan for GraphQL client documents (.graphql) in client directory
|
|
8
|
+
* Excludes files from external service directories
|
|
9
|
+
*/
|
|
10
|
+
async function scanDocumentsCore(ctx, options = {}) {
|
|
11
|
+
const warnings = [];
|
|
12
|
+
const errors = [];
|
|
13
|
+
try {
|
|
14
|
+
const clientDirRelative = options.clientDirRelative || relative(ctx.rootDir, ctx.clientDir);
|
|
15
|
+
const allFiles = await scanWithLayers(ctx, {
|
|
16
|
+
mainDir: ctx.rootDir,
|
|
17
|
+
mainSubDir: clientDirRelative,
|
|
18
|
+
layerDirs: ctx.layerAppDirs,
|
|
19
|
+
layerSubDir: "graphql",
|
|
20
|
+
pattern: GRAPHQL_GLOB_PATTERN
|
|
21
|
+
});
|
|
22
|
+
const externalPatterns = (options.externalServices || []).flatMap((service) => service.documents || []);
|
|
23
|
+
return {
|
|
24
|
+
items: allFiles.filter((f) => !f.path.startsWith("external/")).filter((f) => {
|
|
25
|
+
const relativePath = f.path;
|
|
26
|
+
for (const pattern of externalPatterns) if (pattern.replace(/* @__PURE__ */ new RegExp(`^${clientDirRelative.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/`), "").split("/")[0] === relativePath.split("/")[0]) return false;
|
|
27
|
+
return true;
|
|
28
|
+
}).map((f) => f.fullPath),
|
|
29
|
+
warnings,
|
|
30
|
+
errors
|
|
31
|
+
};
|
|
32
|
+
} catch (error) {
|
|
33
|
+
errors.push(`Document scanning error: ${error}`);
|
|
34
|
+
return {
|
|
35
|
+
items: [],
|
|
36
|
+
warnings,
|
|
37
|
+
errors
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { scanDocumentsCore };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ASTScanConfig, scanWithAST } from "./ast-scanner.mjs";
|
|
2
|
+
import { deduplicateFiles, extractPaths, filterByExtension, scanDirectory } from "./common.mjs";
|
|
3
|
+
import { scanDirectivesCore } from "./directives.mjs";
|
|
4
|
+
import { ScanDocumentsOptions, scanDocumentsCore } from "./documents.mjs";
|
|
5
|
+
import { scanResolversCore } from "./resolvers.mjs";
|
|
6
|
+
import { scanGraphqlCore, scanSchemasCore } from "./schemas.mjs";
|
|
7
|
+
export { type ASTScanConfig, type ScanDocumentsOptions, deduplicateFiles, extractPaths, filterByExtension, scanDirectivesCore, scanDirectory, scanDocumentsCore, scanGraphqlCore, scanResolversCore, scanSchemasCore, scanWithAST };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { deduplicateFiles, extractPaths, filterByExtension, scanDirectory } from "./common.mjs";
|
|
2
|
+
import { scanWithAST } from "./ast-scanner.mjs";
|
|
3
|
+
import { scanDirectivesCore } from "./directives.mjs";
|
|
4
|
+
import { scanDocumentsCore } from "./documents.mjs";
|
|
5
|
+
import { scanResolversCore } from "./resolvers.mjs";
|
|
6
|
+
import { scanGraphqlCore, scanSchemasCore } from "./schemas.mjs";
|
|
7
|
+
|
|
8
|
+
export { deduplicateFiles, extractPaths, filterByExtension, scanDirectivesCore, scanDirectory, scanDocumentsCore, scanGraphqlCore, scanResolversCore, scanSchemasCore, scanWithAST };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ScanContext, ScanResult, ScannedResolver } from "../types/scanning.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/scanning/resolvers.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Scan for resolver files and parse their exports
|
|
7
|
+
*/
|
|
8
|
+
declare function scanResolversCore(ctx: ScanContext): Promise<ScanResult<ScannedResolver>>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { scanResolversCore };
|