nuxt-graphql-middleware 2.1.3 → 3.0.0-beta.0

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.
@@ -0,0 +1,5 @@
1
+ module.exports = function(...args) {
2
+ return import('./module.mjs').then(m => m.default.call(this, ...args))
3
+ }
4
+ const _meta = module.exports.meta = require('./module.json')
5
+ module.exports.getMeta = () => Promise.resolve(_meta)
@@ -0,0 +1,141 @@
1
+ import { NuxtModule } from '@nuxt/schema';
2
+ import { CompatibilityEvent } from 'h3';
3
+ import { FetchOptions } from 'ohmyfetch';
4
+ import { TypeScriptDocumentsPluginConfig } from '@graphql-codegen/typescript-operations';
5
+
6
+ declare type GraphqlMiddlewareGraphqlEndpointMethod = (event?: CompatibilityEvent, operation?: string, operationName?: string) => string;
7
+ declare type GraphqlMiddlewareServerFetchOptionsMethod = (event?: CompatibilityEvent, operation?: string, operationName?: string) => FetchOptions;
8
+ interface GraphqlMiddlewareConfig {
9
+ /**
10
+ * File glob patterns for the auto import feature.
11
+ *
12
+ * If left empty, no documents are auto imported.
13
+ *
14
+ * @default
15
+ * ```json
16
+ * ["**\/.{gql,graphql}", "!node_modules"]
17
+ * ```
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * // Load .graphql files from pages folder and from a node_modules dependency.
22
+ * const autoImportPatterns = [
23
+ * './pages/**\/*.graphql',
24
+ * 'node_modules/my_library/dist/**\/*.graphql'
25
+ * ]
26
+ * ```
27
+ */
28
+ autoImportPatterns?: string[];
29
+ /**
30
+ * Additional raw documents to include.
31
+ *
32
+ * Useful if for example you need to generate queries during build time.
33
+ *
34
+ * @default []
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * const documents = [`
39
+ * query myQuery {
40
+ * articles {
41
+ * title
42
+ * id
43
+ * }
44
+ * }`,
45
+ * ...getGeneratedDocuments()
46
+ * ]
47
+ * ```
48
+ */
49
+ documents?: string[];
50
+ /**
51
+ * Enable detailled debugging messages.
52
+ *
53
+ * @default false
54
+ */
55
+ debug?: boolean;
56
+ /**
57
+ * The URL of the GraphQL server.
58
+ *
59
+ * You can either provide a string or a method that returns a string.
60
+ * If you provide a method it will be called everytime a GraphQL request is
61
+ * made in the server API handler.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * function graphqlEndpoint(event, operation, operationName) {
66
+ * const language = getLanguageFromRequest(event)
67
+ * return `https://api.example.com/${language}/graphql`
68
+ * }
69
+ * ```
70
+ */
71
+ graphqlEndpoint?: string | GraphqlMiddlewareGraphqlEndpointMethod;
72
+ /**
73
+ * The prefix for the server route.
74
+ *
75
+ * @default ```ts
76
+ * "/api/graphql_middleware"
77
+ * ```
78
+ */
79
+ serverApiPrefix?: string;
80
+ /**
81
+ * Provide the options for the ohmyfetch request to the GraphQL server.
82
+ *
83
+ * @default undefined
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * import { getHeader } from 'h3'
88
+ *
89
+ * // Pass the cookie from the client request to the GraphQL request.
90
+ * function serverFetchOptions(event, operation, operationName) {
91
+ * return {
92
+ * headers: {
93
+ * Cookie: getHeader(event, 'cookie')
94
+ * }
95
+ * }
96
+ * }
97
+ * ```
98
+ */
99
+ serverFetchOptions?: FetchOptions | GraphqlMiddlewareServerFetchOptionsMethod;
100
+ /**
101
+ * Download the GraphQL schema and store it in the
102
+ *
103
+ * @default true
104
+ */
105
+ downloadSchema?: boolean;
106
+ /**
107
+ * Path to the GraphQL schema file.
108
+ *
109
+ * If `downloadSchema` is `true`, the downloaded schema is written to this specified path.
110
+ * If `downloadSchema` is `false`, this file must be present in order to generate types.
111
+ *
112
+ * @default './schema.graphql'
113
+ */
114
+ schemaPath?: string;
115
+ /**
116
+ * These options are passed to the graphql-codegen method when generating the operations types.
117
+ *
118
+ * {@link https://www.the-guild.dev/graphql/codegen/plugins/typescript/typescript-operations}
119
+ * @default
120
+ * ```ts
121
+ * const codegenConfig = {
122
+ * exportFragmentSpreadSubTypes: true,
123
+ * preResolveTypes: true,
124
+ * skipTypeNameForRoot: true,
125
+ * skipTypename: true,
126
+ * useTypeImports: true,
127
+ * onlyOperationTypes: true,
128
+ * namingConvention: {
129
+ * enumValues: 'change-case-all#upperCaseFirst',
130
+ * },
131
+ * }
132
+ * ```
133
+ */
134
+ codegenConfig?: TypeScriptDocumentsPluginConfig;
135
+ }
136
+
137
+ declare type ModuleOptions = GraphqlMiddlewareConfig;
138
+ declare type ModuleHooks = {};
139
+ declare const _default: NuxtModule<GraphqlMiddlewareConfig>;
140
+
141
+ export { ModuleHooks, ModuleOptions, _default as default };
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "nuxt-graphql-middleware",
3
+ "configKey": "graphqlMiddleware",
4
+ "version": "3.0.0-beta.0"
5
+ }