nuxt-graphql-middleware 3.1.0-beta.2 → 3.1.0-beta.3
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/module.d.ts +29 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +20 -19
- package/package.json +1 -1
package/dist/module.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { Types } from '@graphql-codegen/plugin-helpers';
|
|
3
|
+
import { SchemaASTConfig } from '@graphql-codegen/schema-ast';
|
|
2
4
|
import { TypeScriptDocumentsPluginConfig } from '@graphql-codegen/typescript-operations';
|
|
3
5
|
import { H3Event } from 'h3';
|
|
4
6
|
import { FetchOptions, FetchResponse, FetchError } from 'ofetch';
|
|
@@ -193,7 +195,8 @@ interface ModuleOptions {
|
|
|
193
195
|
*/
|
|
194
196
|
schemaPath?: string;
|
|
195
197
|
/**
|
|
196
|
-
* These options are passed to the graphql-codegen method when generating the
|
|
198
|
+
* These options are passed to the graphql-codegen method when generating the
|
|
199
|
+
* TypeScript operations types.
|
|
197
200
|
*
|
|
198
201
|
* {@link https://www.the-guild.dev/graphql/codegen/plugins/typescript/typescript-operations}
|
|
199
202
|
* @default
|
|
@@ -212,6 +215,31 @@ interface ModuleOptions {
|
|
|
212
215
|
* ```
|
|
213
216
|
*/
|
|
214
217
|
codegenConfig?: TypeScriptDocumentsPluginConfig;
|
|
218
|
+
/**
|
|
219
|
+
* Configuration for graphql-codegen when downloading the schema.
|
|
220
|
+
*/
|
|
221
|
+
codegenSchemaConfig?: {
|
|
222
|
+
/**
|
|
223
|
+
* Configure how the schema.graphql file should be generated.
|
|
224
|
+
*/
|
|
225
|
+
schemaAstConfig?: SchemaASTConfig;
|
|
226
|
+
/**
|
|
227
|
+
* Configure how the schema-ast introspection request should be made.
|
|
228
|
+
*
|
|
229
|
+
* Usually this is where you can provide a custom authentication header:
|
|
230
|
+
*
|
|
231
|
+
* ```typescript
|
|
232
|
+
* const codegenSchemaConfig = {
|
|
233
|
+
* urlSchemaOptions: {
|
|
234
|
+
* headers: {
|
|
235
|
+
* authentication: 'foobar',
|
|
236
|
+
* }
|
|
237
|
+
* }
|
|
238
|
+
* }
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
urlSchemaOptions?: Types.UrlSchemaOptions;
|
|
242
|
+
};
|
|
215
243
|
}
|
|
216
244
|
type ModuleHooks = {};
|
|
217
245
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import { oldVisit } from '@graphql-codegen/plugin-helpers';
|
|
|
17
17
|
import { pascalCase } from 'change-case-all';
|
|
18
18
|
|
|
19
19
|
const name = "nuxt-graphql-middleware";
|
|
20
|
-
const version = "3.1.0-beta.
|
|
20
|
+
const version = "3.1.0-beta.3";
|
|
21
21
|
|
|
22
22
|
var GraphqlMiddlewareTemplate = /* @__PURE__ */ ((GraphqlMiddlewareTemplate2) => {
|
|
23
23
|
GraphqlMiddlewareTemplate2["OperationTypes"] = "graphql-operations.d.ts";
|
|
@@ -165,24 +165,25 @@ function pluginLoader(name) {
|
|
|
165
165
|
return Promise.resolve(PluginSchemaAst);
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
function generateSchema(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
168
|
+
function generateSchema(moduleOptions, dest, writeToDisk) {
|
|
169
|
+
const pluginConfig = moduleOptions.codegenSchemaConfig?.urlSchemaOptions;
|
|
170
|
+
const schemaAstConfig = moduleOptions.codegenSchemaConfig?.schemaAstConfig || {
|
|
171
|
+
sort: true
|
|
172
|
+
};
|
|
173
|
+
const config = {
|
|
174
|
+
schema: moduleOptions.graphqlEndpoint,
|
|
175
|
+
pluginLoader,
|
|
176
|
+
silent: true,
|
|
177
|
+
errorsOnly: true,
|
|
178
|
+
config: pluginConfig,
|
|
179
|
+
generates: {
|
|
180
|
+
[dest]: {
|
|
181
|
+
plugins: ["schema-ast"],
|
|
182
|
+
config: schemaAstConfig
|
|
182
183
|
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
).then((v) => v[0]);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
return generate$1(config, writeToDisk).then((v) => v[0]);
|
|
186
187
|
}
|
|
187
188
|
function generateTemplates(documents, schemaPath, options) {
|
|
188
189
|
return executeCodegen({
|
|
@@ -353,7 +354,7 @@ async function getSchemaPath(options, resolver, writeToDisk = false) {
|
|
|
353
354
|
if (!options.graphqlEndpoint) {
|
|
354
355
|
throw new Error("Missing graphqlEndpoint config.");
|
|
355
356
|
}
|
|
356
|
-
await generateSchema(options
|
|
357
|
+
await generateSchema(options, dest, writeToDisk);
|
|
357
358
|
return dest;
|
|
358
359
|
}
|
|
359
360
|
async function autoImportDocuments(patterns = [], srcResolver) {
|