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.
- package/dist/module.cjs +5 -0
- package/dist/module.d.ts +141 -0
- package/dist/module.json +5 -0
- package/dist/module.mjs +7020 -257
- package/dist/runtime/composables/index.d.ts +15 -0
- package/dist/runtime/composables/index.mjs +44 -0
- package/dist/runtime/plugin.d.ts +2 -0
- package/dist/runtime/plugin.mjs +9 -0
- package/dist/runtime/serverHandler/helpers/index.d.ts +2 -0
- package/dist/runtime/serverHandler/helpers/index.mjs +4 -0
- package/dist/runtime/serverHandler/index.d.ts +2 -0
- package/dist/runtime/serverHandler/index.mjs +93 -0
- package/dist/types.d.ts +11 -0
- package/package.json +31 -47
- package/dist/plugin.mjs +0 -107
- package/dist/types/codegen.d.ts +0 -13
- package/dist/types/codegen.d.ts.map +0 -1
- package/dist/types/graphqlImport.d.ts +0 -2
- package/dist/types/graphqlImport.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/module.d.ts +0 -18
- package/dist/types/module.d.ts.map +0 -1
- package/dist/types/serverMiddleware.d.ts +0 -13
- package/dist/types/serverMiddleware.d.ts.map +0 -1
- package/dist/types/templates/plugin.d.ts +0 -26
- package/dist/types/templates/plugin.d.ts.map +0 -1
- package/module.cjs +0 -6
- package/types/index.d.ts +0 -32
package/dist/module.cjs
ADDED
package/dist/module.d.ts
ADDED
|
@@ -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 };
|