nuxt-graphql-middleware 5.0.0-alpha.15 → 5.0.0-alpha.17
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/client/200.html +6 -6
- package/dist/client/404.html +6 -6
- package/dist/client/_nuxt/{B2Rg1ezw.js → BM34SYth.js} +1 -1
- package/dist/client/_nuxt/{AZpplOcD.js → CROlboVl.js} +1 -1
- package/dist/client/_nuxt/{M311G39J.js → D5hBL5aZ.js} +3 -3
- package/dist/client/_nuxt/{u9er1db2.js → FTbv7CO6.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/35b756ec-db3a-48e0-a262-4036827a35c5.json +1 -0
- package/dist/client/_nuxt/{Bt6N0bOg.js → lIgCBhS_.js} +2 -2
- package/dist/client/index.html +6 -6
- package/dist/client-options.d.mts +6 -0
- package/dist/client-options.mjs +5 -0
- package/dist/module.d.mts +9 -506
- package/dist/module.json +3 -3
- package/dist/module.mjs +29 -29
- package/dist/runtime/components/CodeFrame.vue +19 -28
- package/dist/runtime/components/CodeFrame.vue.d.ts +7 -0
- package/dist/runtime/components/DevModeOverlay.vue +25 -33
- package/dist/runtime/components/DevModeOverlay.vue.d.ts +3 -0
- package/dist/runtime/components/ErrorExtensions.vue +9 -11
- package/dist/runtime/components/ErrorExtensions.vue.d.ts +5 -0
- package/dist/runtime/components/ErrorGroup.vue +27 -38
- package/dist/runtime/components/ErrorGroup.vue.d.ts +9 -0
- package/dist/runtime/server/api/mutation.js +2 -1
- package/dist/runtime/server/api/query.js +2 -1
- package/dist/runtime/server/utils/doGraphqlRequest.js +3 -2
- package/dist/server-options.d.mts +8 -0
- package/dist/server-options.mjs +5 -0
- package/dist/{module.d.ts → shared/nuxt-graphql-middleware.DLNGE1zJ.d.mts} +15 -88
- package/dist/types.d.mts +1 -7
- package/dist/utils.d.mts +15 -0
- package/dist/utils.mjs +18 -0
- package/package.json +25 -23
- package/dist/client/_nuxt/builds/meta/e8397e32-8634-465d-8c5a-ae7d6f943789.json +0 -1
- package/dist/module.cjs +0 -5
- package/dist/runtime/clientOptions/index.d.ts +0 -2
- package/dist/runtime/clientOptions/index.js +0 -3
- package/dist/runtime/serverOptions/defineGraphqlServerOptions.d.ts +0 -4
- package/dist/runtime/serverOptions/defineGraphqlServerOptions.js +0 -3
- package/dist/runtime/serverOptions/index.d.ts +0 -2
- package/dist/runtime/serverOptions/index.js +0 -2
- package/dist/types.d.ts +0 -7
package/dist/module.d.mts
CHANGED
|
@@ -1,510 +1,14 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import {
|
|
3
|
-
import { SchemaASTConfig } from '@graphql-codegen/schema-ast';
|
|
4
|
-
import { GeneratorOptions, GeneratorOutput } from 'graphql-typescript-deluxe';
|
|
5
|
-
import { GraphQLSchema, GraphQLNamedType } from 'graphql';
|
|
6
|
-
import { Nuxt, ResolvedNuxtTemplate, WatchEvent, HookResult } from 'nuxt/schema';
|
|
7
|
-
import { Resolver } from '@nuxt/kit';
|
|
8
|
-
import { RouterMethod } from 'h3';
|
|
2
|
+
import { M as ModuleContext, a as ModuleOptions } from './shared/nuxt-graphql-middleware.DLNGE1zJ.mjs';
|
|
9
3
|
import { OperationResponseError } from '../dist/runtime/types.js';
|
|
10
|
-
|
|
4
|
+
import { HookResult } from 'nuxt/schema';
|
|
5
|
+
import 'graphql';
|
|
6
|
+
import '@nuxt/kit';
|
|
7
|
+
import 'h3';
|
|
8
|
+
import '@graphql-codegen/plugin-helpers';
|
|
9
|
+
import '@graphql-codegen/schema-ast';
|
|
10
|
+
import 'graphql-typescript-deluxe';
|
|
11
11
|
|
|
12
|
-
interface ModuleOptions {
|
|
13
|
-
/**
|
|
14
|
-
* File glob patterns for the auto import feature.
|
|
15
|
-
*
|
|
16
|
-
* If left empty, no documents are auto imported.
|
|
17
|
-
*
|
|
18
|
-
* @default
|
|
19
|
-
* ```json
|
|
20
|
-
* ["**\/.{gql,graphql}", "!node_modules"]
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* // Load .graphql files from pages folder and from a node_modules dependency.
|
|
26
|
-
* const autoImportPatterns = [
|
|
27
|
-
* './pages/**\/*.graphql',
|
|
28
|
-
* 'node_modules/my_library/dist/**\/*.graphql'
|
|
29
|
-
* ]
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
autoImportPatterns?: string[];
|
|
33
|
-
/**
|
|
34
|
-
* The path where your graphql.config.ts is, relative to the location of nuxt.config.ts.
|
|
35
|
-
*
|
|
36
|
-
* Used to generate the correct paths in the graphql.config.ts file generated by the module.
|
|
37
|
-
*
|
|
38
|
-
* @default "./graphql.config.ts"
|
|
39
|
-
*/
|
|
40
|
-
graphqlConfigFilePath?: string;
|
|
41
|
-
/**
|
|
42
|
-
* Additional raw documents to include.
|
|
43
|
-
*
|
|
44
|
-
* Useful if for example you need to generate queries during build time.
|
|
45
|
-
*
|
|
46
|
-
* @default []
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```ts
|
|
50
|
-
* const documents = [`
|
|
51
|
-
* query myQuery {
|
|
52
|
-
* articles {
|
|
53
|
-
* title
|
|
54
|
-
* id
|
|
55
|
-
* }
|
|
56
|
-
* }`,
|
|
57
|
-
* ...getGeneratedDocuments()
|
|
58
|
-
* ]
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
documents?: string[];
|
|
62
|
-
/**
|
|
63
|
-
* Wether the useGraphqlQuery, useGraphqlMutation and useGraphqlState
|
|
64
|
-
* composables should be included.
|
|
65
|
-
*
|
|
66
|
-
* @default ```ts
|
|
67
|
-
* true
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
includeComposables?: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Enable support for uploading files via GraphQL.
|
|
73
|
-
*
|
|
74
|
-
* When enabled, an additional `useGraphqlUploadMutation` composable is
|
|
75
|
-
* included, in addition to a new server endpoint that handles multi part
|
|
76
|
-
* file uploads for GraphQL mutations.
|
|
77
|
-
*/
|
|
78
|
-
enableFileUploads?: boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Enable detailled debugging messages.
|
|
81
|
-
*
|
|
82
|
-
* @default false
|
|
83
|
-
*/
|
|
84
|
-
debug?: boolean;
|
|
85
|
-
/**
|
|
86
|
-
* Displays GraphQL response errors in an overlay in dev mode.
|
|
87
|
-
*/
|
|
88
|
-
errorOverlay?: boolean;
|
|
89
|
-
/**
|
|
90
|
-
* The URL of the GraphQL server.
|
|
91
|
-
*
|
|
92
|
-
* For the runtime execution you can provide a method that determines the endpoint
|
|
93
|
-
* during runtime. See the server/graphqlMiddleware.serverOptions.ts documentation
|
|
94
|
-
* for more information.
|
|
95
|
-
*/
|
|
96
|
-
graphqlEndpoint: string;
|
|
97
|
-
/**
|
|
98
|
-
* Download the GraphQL schema and store it on disk.
|
|
99
|
-
*
|
|
100
|
-
* Usually you'll want to only enable this during dev mode.
|
|
101
|
-
*
|
|
102
|
-
* @default true
|
|
103
|
-
*/
|
|
104
|
-
downloadSchema?: boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Path to the GraphQL schema file.
|
|
107
|
-
*
|
|
108
|
-
* If `downloadSchema` is `true`, the downloaded schema is written to this specified path.
|
|
109
|
-
* If `downloadSchema` is `false`, this file must be present in order to generate types.
|
|
110
|
-
*
|
|
111
|
-
* @default './schema.graphql'
|
|
112
|
-
*/
|
|
113
|
-
schemaPath?: string;
|
|
114
|
-
/**
|
|
115
|
-
* The prefix for the server route.
|
|
116
|
-
*
|
|
117
|
-
* @default ```ts
|
|
118
|
-
* "/api/graphql_middleware"
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
121
|
-
serverApiPrefix?: string;
|
|
122
|
-
/**
|
|
123
|
-
* Logs only errors.
|
|
124
|
-
*
|
|
125
|
-
* When enabled only errors are logged to the console when generating the GraphQL operations.
|
|
126
|
-
* If false, all operations are logged, including valid ones.
|
|
127
|
-
*/
|
|
128
|
-
logOnlyErrors?: boolean;
|
|
129
|
-
/**
|
|
130
|
-
* Options for graphql-typescript-deluxe code generator.
|
|
131
|
-
*
|
|
132
|
-
* @see [GeneratorOptions](https://github.com/dulnan/graphql-typescript-deluxe/blob/main/src/types/options.ts#L193)
|
|
133
|
-
*/
|
|
134
|
-
codegenConfig?: GeneratorOptions;
|
|
135
|
-
/**
|
|
136
|
-
* Configuration for graphql-codegen when downloading the schema.
|
|
137
|
-
*/
|
|
138
|
-
codegenSchemaConfig?: {
|
|
139
|
-
/**
|
|
140
|
-
* Configure how the schema.graphql file should be generated.
|
|
141
|
-
*
|
|
142
|
-
* @see [SchemaASTConfig](https://github.com/dotansimha/graphql-code-generator/blob/master/packages/plugins/other/schema-ast/src/index.ts#L23)
|
|
143
|
-
*/
|
|
144
|
-
schemaAstConfig?: SchemaASTConfig;
|
|
145
|
-
/**
|
|
146
|
-
* Configure how the schema-ast introspection request should be made.
|
|
147
|
-
*
|
|
148
|
-
* Usually this is where you can provide a custom authentication header:
|
|
149
|
-
*
|
|
150
|
-
* ```typescript
|
|
151
|
-
* const codegenSchemaConfig = {
|
|
152
|
-
* urlSchemaOptions: {
|
|
153
|
-
* headers: {
|
|
154
|
-
* authentication: 'foobar',
|
|
155
|
-
* }
|
|
156
|
-
* }
|
|
157
|
-
* }
|
|
158
|
-
* ```
|
|
159
|
-
*
|
|
160
|
-
* @see [Types.UrlSchemaOptions](https://github.com/dotansimha/graphql-code-generator/blob/master/packages/utils/plugins-helpers/src/types.ts#L82)
|
|
161
|
-
*/
|
|
162
|
-
urlSchemaOptions?: Types.UrlSchemaOptions;
|
|
163
|
-
};
|
|
164
|
-
/**
|
|
165
|
-
* Set to true if you want to output each compiled query and mutation in the
|
|
166
|
-
* .nuxt folder.
|
|
167
|
-
* Set to a path to output to a custom path.
|
|
168
|
-
*/
|
|
169
|
-
outputDocuments?: boolean | string;
|
|
170
|
-
/**
|
|
171
|
-
* Enable Nuxt DevTools integration.
|
|
172
|
-
*/
|
|
173
|
-
devtools?: boolean;
|
|
174
|
-
/**
|
|
175
|
-
* Client caching configuration.
|
|
176
|
-
*/
|
|
177
|
-
clientCache?: {
|
|
178
|
-
enabled?: boolean;
|
|
179
|
-
maxSize?: number;
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
type RpcItem = {
|
|
184
|
-
id: string;
|
|
185
|
-
timestamp?: number;
|
|
186
|
-
source: string;
|
|
187
|
-
name: string;
|
|
188
|
-
identifier: 'fragment' | 'query' | 'mutation';
|
|
189
|
-
filePath: string;
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
declare const defaultOptions: ModuleOptions;
|
|
193
|
-
|
|
194
|
-
declare class ConsolePrompt {
|
|
195
|
-
private abortController;
|
|
196
|
-
confirm(message: string): Promise<'yes' | 'no' | 'cancel'>;
|
|
197
|
-
abort(): void;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
type TemplateOptions = {
|
|
201
|
-
path: string;
|
|
202
|
-
virtual?: boolean;
|
|
203
|
-
};
|
|
204
|
-
type GeneratorTemplateCallback = (output: GeneratorOutput, helper: ModuleHelper) => string;
|
|
205
|
-
type StaticTemplateCallback = (helper: ModuleHelper) => string;
|
|
206
|
-
type GeneratorTemplate = {
|
|
207
|
-
type: 'generator';
|
|
208
|
-
options: TemplateOptions;
|
|
209
|
-
build: GeneratorTemplateCallback | null;
|
|
210
|
-
buildTypes: GeneratorTemplateCallback | null;
|
|
211
|
-
virtual?: boolean;
|
|
212
|
-
};
|
|
213
|
-
type StaticTemplate = {
|
|
214
|
-
type: 'static';
|
|
215
|
-
options: TemplateOptions;
|
|
216
|
-
build: StaticTemplateCallback | null;
|
|
217
|
-
buildTypes: StaticTemplateCallback | null;
|
|
218
|
-
virtual?: boolean;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
type WithRequired<T, K extends keyof T> = T & {
|
|
222
|
-
[P in K]-?: T[P];
|
|
223
|
-
};
|
|
224
|
-
type RequiredModuleOptions = WithRequired<ModuleOptions, keyof typeof defaultOptions>;
|
|
225
|
-
type ModuleHelperResolvers = {
|
|
226
|
-
/**
|
|
227
|
-
* Resolver for paths relative to the module root.
|
|
228
|
-
*/
|
|
229
|
-
module: Resolver;
|
|
230
|
-
/**
|
|
231
|
-
* Resolve relative to the app's server directory.
|
|
232
|
-
*/
|
|
233
|
-
server: Resolver;
|
|
234
|
-
/**
|
|
235
|
-
* Resolve relative to the Nuxt src folder.
|
|
236
|
-
*/
|
|
237
|
-
src: Resolver;
|
|
238
|
-
/**
|
|
239
|
-
* Resolve relative to the Nuxt app directory.
|
|
240
|
-
*/
|
|
241
|
-
app: Resolver;
|
|
242
|
-
/**
|
|
243
|
-
* Resolve relative to the Nuxt root.
|
|
244
|
-
*
|
|
245
|
-
* Should be where nuxt.config.ts is located.
|
|
246
|
-
*/
|
|
247
|
-
root: Resolver;
|
|
248
|
-
};
|
|
249
|
-
type ModuleHelperPaths = {
|
|
250
|
-
runtimeTypes: string;
|
|
251
|
-
root: string;
|
|
252
|
-
nuxtConfig: string;
|
|
253
|
-
serverDir: string;
|
|
254
|
-
schema: string;
|
|
255
|
-
serverOptions: string | null;
|
|
256
|
-
clientOptions: string | null;
|
|
257
|
-
moduleBuildDir: string;
|
|
258
|
-
moduleTypesDir: string;
|
|
259
|
-
};
|
|
260
|
-
declare class ModuleHelper {
|
|
261
|
-
private nuxt;
|
|
262
|
-
readonly resolvers: ModuleHelperResolvers;
|
|
263
|
-
readonly paths: ModuleHelperPaths;
|
|
264
|
-
readonly isDev: boolean;
|
|
265
|
-
readonly options: RequiredModuleOptions;
|
|
266
|
-
readonly prompt: ConsolePrompt;
|
|
267
|
-
private nitroExternals;
|
|
268
|
-
private tsPaths;
|
|
269
|
-
constructor(nuxt: Nuxt, moduleUrl: string, options: ModuleOptions);
|
|
270
|
-
/**
|
|
271
|
-
* Find the path to the graphqlMiddleware.serverOptions.ts file.
|
|
272
|
-
*/
|
|
273
|
-
private findServerOptions;
|
|
274
|
-
private findClientOptions;
|
|
275
|
-
/**
|
|
276
|
-
* Transform the path relative to the module's build directory.
|
|
277
|
-
*
|
|
278
|
-
* @param path - The absolute path.
|
|
279
|
-
*
|
|
280
|
-
* @returns The path relative to the module's build directory.
|
|
281
|
-
*/
|
|
282
|
-
toModuleBuildRelative(path: string): string;
|
|
283
|
-
/**
|
|
284
|
-
* Transform the path relative to the Nuxt build directory.
|
|
285
|
-
*
|
|
286
|
-
* @param path - The absolute path.
|
|
287
|
-
*
|
|
288
|
-
* @returns The path relative to the module's build directory.
|
|
289
|
-
*/
|
|
290
|
-
toBuildRelative(path: string): string;
|
|
291
|
-
/**
|
|
292
|
-
* Get all file paths that match the import patterns.
|
|
293
|
-
*/
|
|
294
|
-
getImportPatternFiles(): Promise<string[]>;
|
|
295
|
-
matchesImportPattern(filePath: string): boolean;
|
|
296
|
-
addAlias(name: string, path: string): void;
|
|
297
|
-
inlineNitroExternals(arg: ResolvedNuxtTemplate | string): void;
|
|
298
|
-
transpile(path: string): void;
|
|
299
|
-
applyBuildConfig(): void;
|
|
300
|
-
processTemplate(path: string, content: string): string;
|
|
301
|
-
addTemplate(template: StaticTemplate): void;
|
|
302
|
-
addPlugin(name: string): void;
|
|
303
|
-
addServerHandler(name: string, path: string, method: RouterMethod): void;
|
|
304
|
-
addComposable(name: string): void;
|
|
305
|
-
addServerUtil(name: string): void;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
type CollectorWatchEventResult = {
|
|
309
|
-
hasChanged: boolean;
|
|
310
|
-
affectedOperations: string[];
|
|
311
|
-
error?: {
|
|
312
|
-
message: string;
|
|
313
|
-
};
|
|
314
|
-
};
|
|
315
|
-
declare class Collector {
|
|
316
|
-
private schema;
|
|
317
|
-
private helper;
|
|
318
|
-
/**
|
|
319
|
-
* All collected files.
|
|
320
|
-
*/
|
|
321
|
-
private files;
|
|
322
|
-
/**
|
|
323
|
-
* All documents provided by hooks.
|
|
324
|
-
*/
|
|
325
|
-
private hookDocuments;
|
|
326
|
-
/**
|
|
327
|
-
* All file paths provided by hooks.
|
|
328
|
-
*/
|
|
329
|
-
private hookFiles;
|
|
330
|
-
/**
|
|
331
|
-
* The code generator.
|
|
332
|
-
*/
|
|
333
|
-
private generator;
|
|
334
|
-
/**
|
|
335
|
-
* A map of operation name and timestamp when the operation was last validated.
|
|
336
|
-
*/
|
|
337
|
-
private operationTimestamps;
|
|
338
|
-
/**
|
|
339
|
-
* The generated operations and fragments.
|
|
340
|
-
*/
|
|
341
|
-
readonly rpcItems: Map<string, RpcItem>;
|
|
342
|
-
/**
|
|
343
|
-
* The registered templates.
|
|
344
|
-
*/
|
|
345
|
-
private templates;
|
|
346
|
-
/**
|
|
347
|
-
* The generated template contents.
|
|
348
|
-
*/
|
|
349
|
-
private templateResult;
|
|
350
|
-
constructor(schema: GraphQLSchema, helper: ModuleHelper);
|
|
351
|
-
reset(): Promise<void>;
|
|
352
|
-
updateSchema(schema: GraphQLSchema): Promise<void>;
|
|
353
|
-
private filePathToBuildRelative;
|
|
354
|
-
private filePathToSourceRelative;
|
|
355
|
-
private operationToLogEntry;
|
|
356
|
-
private getTemplate;
|
|
357
|
-
/**
|
|
358
|
-
* Executes code gen and performs validation for operations.
|
|
359
|
-
*/
|
|
360
|
-
private buildState;
|
|
361
|
-
private buildErrorMessage;
|
|
362
|
-
private logError;
|
|
363
|
-
/**
|
|
364
|
-
* Initialise the collector.
|
|
365
|
-
*
|
|
366
|
-
* In dev mode, the method will call itself recursively until all documents
|
|
367
|
-
* are valid.
|
|
368
|
-
*
|
|
369
|
-
* If not in dev mode the method will throw an error when documents are not
|
|
370
|
-
* valid.
|
|
371
|
-
*/
|
|
372
|
-
init(): Promise<void>;
|
|
373
|
-
addHookDocument(identifier: string, source: string): void;
|
|
374
|
-
addHookFile(filePath: string): void;
|
|
375
|
-
/**
|
|
376
|
-
* Initialise the collector.
|
|
377
|
-
*/
|
|
378
|
-
private initDocuments;
|
|
379
|
-
/**
|
|
380
|
-
* Add a file.
|
|
381
|
-
*/
|
|
382
|
-
private addFile;
|
|
383
|
-
private matchesPatternOrExists;
|
|
384
|
-
private handleAdd;
|
|
385
|
-
private handleChange;
|
|
386
|
-
private handleUnlink;
|
|
387
|
-
private handleUnlinkDir;
|
|
388
|
-
/**
|
|
389
|
-
* Handle the watcher event for the given file path.
|
|
390
|
-
*/
|
|
391
|
-
handleWatchEvent(event: WatchEvent, filePath: string): Promise<CollectorWatchEventResult>;
|
|
392
|
-
/**
|
|
393
|
-
* Adds a virtual template (not written to disk) for both Nuxt and Nitro.
|
|
394
|
-
*
|
|
395
|
-
* For some reason a template written to disk works for both Nuxt and Nitro,
|
|
396
|
-
* but a virtual template requires adding two templates.
|
|
397
|
-
*/
|
|
398
|
-
private addVirtualTemplate;
|
|
399
|
-
/**
|
|
400
|
-
* Adds a template that dependes on Collector state.
|
|
401
|
-
*/
|
|
402
|
-
addTemplate(template: GeneratorTemplate): void;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* Handles downloading, loading and saving the GraphQL schema.
|
|
407
|
-
*/
|
|
408
|
-
declare class SchemaProvider {
|
|
409
|
-
private helper;
|
|
410
|
-
/**
|
|
411
|
-
* The raw schema content.
|
|
412
|
-
*/
|
|
413
|
-
private schemaContent;
|
|
414
|
-
/**
|
|
415
|
-
* The parsed schema object.
|
|
416
|
-
*/
|
|
417
|
-
private schema;
|
|
418
|
-
constructor(helper: ModuleHelper);
|
|
419
|
-
init(): Promise<void>;
|
|
420
|
-
private loadFromDiskFallback;
|
|
421
|
-
/**
|
|
422
|
-
* Loads the schema from disk.
|
|
423
|
-
*
|
|
424
|
-
* @returns The schema contents from disk.
|
|
425
|
-
*/
|
|
426
|
-
private loadSchemaFromDisk;
|
|
427
|
-
/**
|
|
428
|
-
* Downloads the schema and saves it to disk.
|
|
429
|
-
*
|
|
430
|
-
* @returns The schema contents.
|
|
431
|
-
*/
|
|
432
|
-
private downloadSchema;
|
|
433
|
-
/**
|
|
434
|
-
* Determine if the schema exists on disk.
|
|
435
|
-
*
|
|
436
|
-
* @returns True if the schema file exists on disk.
|
|
437
|
-
*/
|
|
438
|
-
hasSchemaOnDisk(): Promise<boolean>;
|
|
439
|
-
/**
|
|
440
|
-
* Load the schema either from disk or by downloading it.
|
|
441
|
-
*
|
|
442
|
-
* @param forceDownload - Forces downloading the schema.
|
|
443
|
-
*/
|
|
444
|
-
loadSchema(opts?: {
|
|
445
|
-
forceDownload?: boolean;
|
|
446
|
-
forceDisk?: boolean;
|
|
447
|
-
}): Promise<void>;
|
|
448
|
-
/**
|
|
449
|
-
* Get the schema.
|
|
450
|
-
*
|
|
451
|
-
* @returns The parsed GraphQL schema object.
|
|
452
|
-
*/
|
|
453
|
-
getSchema(): GraphQLSchema;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* The public module context class.
|
|
458
|
-
*/
|
|
459
|
-
declare class ModuleContext {
|
|
460
|
-
private schemaProvider;
|
|
461
|
-
private collector;
|
|
462
|
-
constructor(schemaProvider: SchemaProvider, collector: Collector);
|
|
463
|
-
/**
|
|
464
|
-
* Return the GraphQL schema.
|
|
465
|
-
*
|
|
466
|
-
* Note that the schema may be updated during development, so it can become
|
|
467
|
-
* stale. Prefer using methods like `schemaHasType()` to query the schema.
|
|
468
|
-
*
|
|
469
|
-
* @returns The GraphQL schema.
|
|
470
|
-
*/
|
|
471
|
-
getSchema(): GraphQLSchema;
|
|
472
|
-
/**
|
|
473
|
-
* Check if the given GraphQL type (interface, concrete type, enum, input type)
|
|
474
|
-
* exists in the schema.
|
|
475
|
-
*
|
|
476
|
-
* @param name - The name of the type.
|
|
477
|
-
*
|
|
478
|
-
* @returns True if the type exists in the schema.
|
|
479
|
-
*/
|
|
480
|
-
schemaHasType(name: string): boolean;
|
|
481
|
-
/**
|
|
482
|
-
* Get a type from the schema.
|
|
483
|
-
*
|
|
484
|
-
* @param name - The name of the type.
|
|
485
|
-
*
|
|
486
|
-
* @returns The type.
|
|
487
|
-
*/
|
|
488
|
-
schemaGetType(name: string): GraphQLNamedType | undefined;
|
|
489
|
-
/**
|
|
490
|
-
* Add an additional static document.
|
|
491
|
-
*
|
|
492
|
-
* @param identifier - The unique identifier for your document.
|
|
493
|
-
* @param source - The document source.
|
|
494
|
-
*/
|
|
495
|
-
addDocument(identifier: string, source: string): ModuleContext;
|
|
496
|
-
/**
|
|
497
|
-
* Add an additional GraphQL file to import.
|
|
498
|
-
*
|
|
499
|
-
* @param filePath - The absolute path to the file.
|
|
500
|
-
*/
|
|
501
|
-
addImportFile(filePath: string): ModuleContext;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
declare function useGraphqlModuleContext(): ModuleContext;
|
|
505
|
-
declare function useGraphqlModuleContext(options: {
|
|
506
|
-
nullOnMissing: true;
|
|
507
|
-
}): ModuleContext | null;
|
|
508
12
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
509
13
|
|
|
510
14
|
declare module '#app' {
|
|
@@ -571,5 +75,4 @@ declare module '@nuxt/schema' {
|
|
|
571
75
|
}
|
|
572
76
|
}
|
|
573
77
|
|
|
574
|
-
export { _default as default
|
|
575
|
-
export type { ModuleOptions };
|
|
78
|
+
export { ModuleOptions, _default as default };
|
package/dist/module.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-graphql-middleware",
|
|
3
3
|
"configKey": "graphqlMiddleware",
|
|
4
|
-
"version": "5.0.0-alpha.
|
|
4
|
+
"version": "5.0.0-alpha.17",
|
|
5
5
|
"compatibility": {
|
|
6
6
|
"nuxt": ">=3.15.0"
|
|
7
7
|
},
|
|
8
8
|
"builder": {
|
|
9
|
-
"@nuxt/module-builder": "0.
|
|
10
|
-
"unbuild": "
|
|
9
|
+
"@nuxt/module-builder": "1.0.1",
|
|
10
|
+
"unbuild": "3.5.0"
|
|
11
11
|
}
|
|
12
12
|
}
|
package/dist/module.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from 'url';
|
|
2
|
-
import { useLogger, addTemplate, addServerTemplate, addTypeTemplate, createResolver, resolveAlias, resolveFiles, addPlugin, addServerHandler, addImports, addServerImports, useNitro, defineNuxtModule
|
|
2
|
+
import { useLogger, addTemplate, addServerTemplate, addTypeTemplate, createResolver, resolveAlias, resolveFiles, addPlugin, addServerHandler, addImports, addServerImports, useNitro, defineNuxtModule } from '@nuxt/kit';
|
|
3
3
|
import { existsSync, promises } from 'node:fs';
|
|
4
4
|
import { basename } from 'node:path';
|
|
5
5
|
import { relative } from 'pathe';
|
|
@@ -19,7 +19,7 @@ import { existsSync as existsSync$1 } from 'fs';
|
|
|
19
19
|
import { onDevToolsInitialized, extendServerRpc } from '@nuxt/devtools-kit';
|
|
20
20
|
|
|
21
21
|
const name = "nuxt-graphql-middleware";
|
|
22
|
-
const version = "5.0.0-alpha.
|
|
22
|
+
const version = "5.0.0-alpha.17";
|
|
23
23
|
|
|
24
24
|
const logger = useLogger("nuxt-graphql-middleware");
|
|
25
25
|
const defaultOptions = {
|
|
@@ -119,6 +119,9 @@ class CollectedFile {
|
|
|
119
119
|
}
|
|
120
120
|
static async fromFilePath(filePath) {
|
|
121
121
|
const content = (await promises.readFile(filePath)).toString();
|
|
122
|
+
if (!content) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
122
125
|
return new CollectedFile(filePath, content, true);
|
|
123
126
|
}
|
|
124
127
|
/**
|
|
@@ -411,7 +414,7 @@ class Collector {
|
|
|
411
414
|
*/
|
|
412
415
|
async addFile(filePath) {
|
|
413
416
|
const file = await CollectedFile.fromFilePath(filePath);
|
|
414
|
-
if (!file
|
|
417
|
+
if (!file?.fileContents) {
|
|
415
418
|
return null;
|
|
416
419
|
}
|
|
417
420
|
this.files.set(filePath, file);
|
|
@@ -1049,16 +1052,16 @@ export { clientOptions }
|
|
|
1049
1052
|
helper.paths.clientOptions
|
|
1050
1053
|
);
|
|
1051
1054
|
return `import type { GraphqlClientOptions } from '${helper.paths.runtimeTypes}'
|
|
1052
|
-
import
|
|
1053
|
-
|
|
1054
|
-
export type GraphqlClientContext = typeof clientOptions extends GraphqlClientOptions<infer R> ? R : {}
|
|
1055
|
+
import clientOptionsImport from '${pathRelative}'
|
|
1055
1056
|
|
|
1056
|
-
export
|
|
1057
|
+
declare export const clientOptions: GraphqlClientOptions
|
|
1058
|
+
export type GraphqlClientContext = typeof clientOptionsImport extends GraphqlClientOptions<infer R> ? R : {}
|
|
1059
|
+
`;
|
|
1057
1060
|
}
|
|
1058
1061
|
return `
|
|
1059
1062
|
import type { GraphqlClientOptions } from '${helper.paths.runtimeTypes}'
|
|
1060
|
-
export const clientOptions: GraphqlClientOptions
|
|
1061
1063
|
|
|
1064
|
+
declare export const clientOptions: GraphqlClientOptions
|
|
1062
1065
|
export type GraphqlClientContext = {}
|
|
1063
1066
|
`;
|
|
1064
1067
|
}
|
|
@@ -1225,16 +1228,27 @@ export { serverOptions }
|
|
|
1225
1228
|
`;
|
|
1226
1229
|
},
|
|
1227
1230
|
(helper) => {
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
+
if (helper.paths.serverOptions) {
|
|
1232
|
+
const resolvedPathRelative = helper.toModuleBuildRelative(
|
|
1233
|
+
helper.paths.serverOptions
|
|
1234
|
+
);
|
|
1235
|
+
return `
|
|
1231
1236
|
import type { GraphqlMiddlewareServerOptions } from '${helper.paths.runtimeTypes}'
|
|
1232
|
-
${
|
|
1237
|
+
import serverOptionsImport from '${resolvedPathRelative}'
|
|
1233
1238
|
|
|
1234
1239
|
export type GraphqlResponseAdditions =
|
|
1235
|
-
typeof
|
|
1240
|
+
typeof serverOptionsImport extends GraphqlMiddlewareServerOptions<infer R, any, any> ? R : {}
|
|
1236
1241
|
|
|
1237
|
-
export
|
|
1242
|
+
declare export const serverOptions: GraphqlMiddlewareServerOptions
|
|
1243
|
+
`;
|
|
1244
|
+
}
|
|
1245
|
+
return `
|
|
1246
|
+
import type { GraphqlMiddlewareServerOptions } from '${helper.paths.runtimeTypes}'
|
|
1247
|
+
|
|
1248
|
+
declare export const serverOptions: GraphqlMiddlewareServerOptions
|
|
1249
|
+
|
|
1250
|
+
export type GraphqlResponseAdditions = object
|
|
1251
|
+
`;
|
|
1238
1252
|
}
|
|
1239
1253
|
);
|
|
1240
1254
|
|
|
@@ -1505,20 +1519,6 @@ class ModuleContext {
|
|
|
1505
1519
|
}
|
|
1506
1520
|
}
|
|
1507
1521
|
|
|
1508
|
-
const CONTEXT_KEY = "_nuxt_graphql_middleware";
|
|
1509
|
-
function useGraphqlModuleContext(options) {
|
|
1510
|
-
const nuxt = useNuxt();
|
|
1511
|
-
const context = nuxt[CONTEXT_KEY];
|
|
1512
|
-
if (!context) {
|
|
1513
|
-
if (options?.nullOnMissing) {
|
|
1514
|
-
return null;
|
|
1515
|
-
}
|
|
1516
|
-
throw new Error(
|
|
1517
|
-
"nuxt-graphql-middleware context is not available. Make sure you call this method only after nuxt-graphql-middleware has been setup. If you call this in a module, make sure your module is declared after nuxt-graphql-middleware in your `modules` Nuxt config."
|
|
1518
|
-
);
|
|
1519
|
-
}
|
|
1520
|
-
return context;
|
|
1521
|
-
}
|
|
1522
1522
|
const module = defineNuxtModule({
|
|
1523
1523
|
meta: {
|
|
1524
1524
|
name,
|
|
@@ -1598,4 +1598,4 @@ const module = defineNuxtModule({
|
|
|
1598
1598
|
}
|
|
1599
1599
|
});
|
|
1600
1600
|
|
|
1601
|
-
export { module as default
|
|
1601
|
+
export { module as default };
|