nuxt-graphql-middleware 5.2.3 → 5.3.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/README.md +2 -0
- package/dist/client/200.html +1 -1
- package/dist/client/404.html +1 -1
- package/dist/client/_nuxt/CqRv5mwS.js +2 -0
- package/dist/client/_nuxt/{gyQx9VSj.js → D95LLO0l.js} +1 -1
- package/dist/client/_nuxt/{DyBqp5hr.js → DZ-uq6Vd.js} +1 -1
- package/dist/client/_nuxt/DrXVleME.js +4 -0
- package/dist/client/_nuxt/{BPB7Y782.js → Dx-h1-qv.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/f3f3372e-493e-4c8e-9dbd-18d4c5406f44.json +1 -0
- package/dist/client/index.html +1 -1
- package/dist/module.d.mts +1 -1
- package/dist/module.json +3 -3
- package/dist/module.mjs +1526 -70
- package/dist/runtime/components/CodeFrame.d.vue.ts +8 -0
- package/dist/runtime/components/CodeFrame.vue.d.ts +2 -1
- package/dist/runtime/components/DevModeOverlay.d.vue.ts +4 -0
- package/dist/runtime/components/DevModeOverlay.vue.d.ts +2 -1
- package/dist/runtime/components/ErrorExtensions.d.vue.ts +6 -0
- package/dist/runtime/components/ErrorExtensions.vue.d.ts +2 -1
- package/dist/runtime/components/ErrorGroup.d.vue.ts +10 -0
- package/dist/runtime/components/ErrorGroup.vue.d.ts +2 -1
- package/dist/runtime/helpers/composables.d.ts +1 -40
- package/dist/runtime/helpers/composables.js +3 -12
- package/dist/runtime/helpers/shared-types.d.ts +40 -0
- package/dist/runtime/helpers/shared-types.js +12 -0
- package/dist/runtime/server/api/doRequest.d.ts +2 -0
- package/dist/runtime/server/api/doRequest.js +18 -0
- package/dist/runtime/server/helpers/index.js +1 -1
- package/dist/runtime/server/mcp/index.d.ts +2 -0
- package/dist/runtime/server/mcp/index.js +63 -0
- package/dist/runtime/server/mcp/resources/docs.d.ts +2 -0
- package/dist/runtime/server/mcp/resources/docs.js +36 -0
- package/dist/runtime/server/mcp/tools/fragments-get/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/fragments-get/index.js +35 -0
- package/dist/runtime/server/mcp/tools/fragments-get/types.d.ts +20 -0
- package/dist/runtime/server/mcp/tools/fragments-get/types.js +13 -0
- package/dist/runtime/server/mcp/tools/fragments-get-source/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/fragments-get-source/index.js +34 -0
- package/dist/runtime/server/mcp/tools/fragments-get-source/types.d.ts +10 -0
- package/dist/runtime/server/mcp/tools/fragments-get-source/types.js +9 -0
- package/dist/runtime/server/mcp/tools/fragments-list/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/fragments-list/index.js +36 -0
- package/dist/runtime/server/mcp/tools/fragments-list/types.d.ts +20 -0
- package/dist/runtime/server/mcp/tools/fragments-list/types.js +14 -0
- package/dist/runtime/server/mcp/tools/fragments-list-for-type/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/fragments-list-for-type/index.js +39 -0
- package/dist/runtime/server/mcp/tools/fragments-list-for-type/types.d.ts +31 -0
- package/dist/runtime/server/mcp/tools/fragments-list-for-type/types.js +23 -0
- package/dist/runtime/server/mcp/tools/graphql-execute/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/graphql-execute/index.js +59 -0
- package/dist/runtime/server/mcp/tools/module-get-config/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/module-get-config/index.js +23 -0
- package/dist/runtime/server/mcp/tools/module-get-config/types.d.ts +39 -0
- package/dist/runtime/server/mcp/tools/module-get-config/types.js +26 -0
- package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/index.js +36 -0
- package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/types.d.ts +49 -0
- package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/types.js +24 -0
- package/dist/runtime/server/mcp/tools/operations-execute/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/operations-execute/index.js +63 -0
- package/dist/runtime/server/mcp/tools/operations-get/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/operations-get/index.js +40 -0
- package/dist/runtime/server/mcp/tools/operations-get/types.d.ts +32 -0
- package/dist/runtime/server/mcp/tools/operations-get/types.js +18 -0
- package/dist/runtime/server/mcp/tools/operations-get-field-usage/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/operations-get-field-usage/index.js +39 -0
- package/dist/runtime/server/mcp/tools/operations-get-field-usage/types.d.ts +38 -0
- package/dist/runtime/server/mcp/tools/operations-get-field-usage/types.js +19 -0
- package/dist/runtime/server/mcp/tools/operations-get-source/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/operations-get-source/index.js +39 -0
- package/dist/runtime/server/mcp/tools/operations-get-source/types.d.ts +10 -0
- package/dist/runtime/server/mcp/tools/operations-get-source/types.js +9 -0
- package/dist/runtime/server/mcp/tools/operations-list/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/operations-list/index.js +46 -0
- package/dist/runtime/server/mcp/tools/operations-list/types.d.ts +53 -0
- package/dist/runtime/server/mcp/tools/operations-list/types.js +33 -0
- package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/index.js +37 -0
- package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/types.d.ts +24 -0
- package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/types.js +16 -0
- package/dist/runtime/server/mcp/tools/schema-get-type/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/schema-get-type/index.js +31 -0
- package/dist/runtime/server/mcp/tools/schema-get-type/types.d.ts +112 -0
- package/dist/runtime/server/mcp/tools/schema-get-type/types.js +45 -0
- package/dist/runtime/server/mcp/tools/schema-get-type-definition/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/schema-get-type-definition/index.js +33 -0
- package/dist/runtime/server/mcp/tools/schema-get-type-definition/types.d.ts +10 -0
- package/dist/runtime/server/mcp/tools/schema-get-type-definition/types.js +9 -0
- package/dist/runtime/server/mcp/tools/schema-get-type-usage/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/schema-get-type-usage/index.js +35 -0
- package/dist/runtime/server/mcp/tools/schema-get-type-usage/types.d.ts +39 -0
- package/dist/runtime/server/mcp/tools/schema-get-type-usage/types.js +17 -0
- package/dist/runtime/server/mcp/tools/schema-get-union-members/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/schema-get-union-members/index.js +35 -0
- package/dist/runtime/server/mcp/tools/schema-get-union-members/types.d.ts +24 -0
- package/dist/runtime/server/mcp/tools/schema-get-union-members/types.js +16 -0
- package/dist/runtime/server/mcp/tools/schema-list-types/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/schema-list-types/index.js +37 -0
- package/dist/runtime/server/mcp/tools/schema-list-types/types.d.ts +53 -0
- package/dist/runtime/server/mcp/tools/schema-list-types/types.js +21 -0
- package/dist/runtime/server/mcp/tools/schema-validate-document/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/schema-validate-document/index.js +31 -0
- package/dist/runtime/server/mcp/tools/schema-validate-document/types.d.ts +26 -0
- package/dist/runtime/server/mcp/tools/schema-validate-document/types.js +21 -0
- package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/index.d.ts +1 -0
- package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/index.js +36 -0
- package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/types.d.ts +49 -0
- package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/types.js +24 -0
- package/dist/runtime/server/mcp/utils/index.d.ts +48 -0
- package/dist/runtime/server/mcp/utils/index.js +35 -0
- package/dist/runtime/server/utils/useGraphqlMutation.d.ts +1 -1
- package/dist/runtime/server/utils/useGraphqlMutation.js +1 -1
- package/dist/runtime/server/utils/useGraphqlQuery.d.ts +1 -1
- package/dist/runtime/server/utils/useGraphqlQuery.js +1 -1
- package/dist/shared/{nuxt-graphql-middleware.ct2xvPoD.d.mts → nuxt-graphql-middleware.COufMnWs.d.mts} +119 -2
- package/dist/utils.d.mts +1 -1
- package/docs/composables/useAsyncGraphqlQuery.md +313 -0
- package/docs/composables/useGraphqlMutation.md +29 -0
- package/docs/composables/useGraphqlQuery.md +73 -0
- package/docs/composables/useGraphqlState.md +58 -0
- package/docs/composables/useGraphqlUploadMutation.md +57 -0
- package/docs/configuration/client-options.md +121 -0
- package/docs/configuration/module-hooks.md +112 -0
- package/docs/configuration/module-utils.md +53 -0
- package/docs/configuration/module.md +415 -0
- package/docs/configuration/runtime-config.md +23 -0
- package/docs/configuration/server-options.md +230 -0
- package/package.json +101 -44
- package/dist/client/_nuxt/Bkyil6hz.js +0 -2
- package/dist/client/_nuxt/C9p-Va5c.js +0 -29
- package/dist/client/_nuxt/builds/meta/77b9a31d-6d5c-4e28-9320-cbd287a46883.json +0 -1
- package/dist/runtime/server/tsconfig.json +0 -3
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Module Hooks
|
|
2
|
+
|
|
3
|
+
You can hook into the module's build to add or alter the documents.
|
|
4
|
+
|
|
5
|
+
## `nuxt-graphql-middleware:init`
|
|
6
|
+
|
|
7
|
+
This hook is called right before processing the initial set of GraphQL
|
|
8
|
+
documents, after all modules have been initialised. It allows you to add
|
|
9
|
+
additional documents as strings.
|
|
10
|
+
|
|
11
|
+
### Example in `nuxt.config.ts`
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
export default defineNuxtConfig({
|
|
15
|
+
hooks: {
|
|
16
|
+
'nuxt-graphql-middleware:init': (ctx) => {
|
|
17
|
+
ctx.addDocument(
|
|
18
|
+
'queryFromHook',
|
|
19
|
+
`query queryFromHook {
|
|
20
|
+
users {
|
|
21
|
+
id
|
|
22
|
+
}
|
|
23
|
+
}`,
|
|
24
|
+
)
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Example in Custom Module
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { defineNuxtModule, createResolver } from '@nuxt/kit'
|
|
34
|
+
import { fileURLToPath } from 'url'
|
|
35
|
+
import { isObjectType } from 'graphql'
|
|
36
|
+
|
|
37
|
+
const QUERY = `
|
|
38
|
+
query loadComments {
|
|
39
|
+
comments {
|
|
40
|
+
...comment
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
`
|
|
44
|
+
|
|
45
|
+
export default defineNuxtModule({
|
|
46
|
+
meta: {
|
|
47
|
+
name: 'nuxt-graphql-middleware-playground',
|
|
48
|
+
},
|
|
49
|
+
setup(_options, nuxt) {
|
|
50
|
+
// Resolve files relative to this module.
|
|
51
|
+
const resolver = createResolver(import.meta.url)
|
|
52
|
+
|
|
53
|
+
nuxt.hooks.hookOnce('nuxt-graphql-middleware:init', (context) => {
|
|
54
|
+
// Make sure the schema contains a required type.
|
|
55
|
+
if (!context.schemaHasType('Comment')) {
|
|
56
|
+
throw new Error('Module requires type "Comment" to exist.')
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
context.addDocument('queryFromModule', QUERY)
|
|
60
|
+
|
|
61
|
+
// Add a document on disk via its absolute path.
|
|
62
|
+
const filePath = resolver.resolve('./graphql/queryFromDisk.graphql')
|
|
63
|
+
context.addImportFile(filePath)
|
|
64
|
+
|
|
65
|
+
// Get a GraphQLNamedType from the schema.
|
|
66
|
+
const type = context.schemaGetType('Comment')!
|
|
67
|
+
if (!isObjectType(type)) {
|
|
68
|
+
throw new Error('"Comment" should be an object type.')
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Check for existance of certain fields on a type.
|
|
72
|
+
const fields = type.getFields()
|
|
73
|
+
const hasAuthorField = !!fields.author
|
|
74
|
+
|
|
75
|
+
// Add a fragment with conditional fields.
|
|
76
|
+
context.addDocument(
|
|
77
|
+
'commentFragmentFromModule',
|
|
78
|
+
`fragment comment on Comment {
|
|
79
|
+
${hasAuthorField ? 'author' : ''}
|
|
80
|
+
body
|
|
81
|
+
subject
|
|
82
|
+
}`,
|
|
83
|
+
)
|
|
84
|
+
})
|
|
85
|
+
},
|
|
86
|
+
})
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## `nuxt-graphql-middleware:build`
|
|
90
|
+
|
|
91
|
+
This hook is called whenever the internal state of all GraphQL documents was
|
|
92
|
+
rebuilt. It receives a context object that contains a `output` property
|
|
93
|
+
containing the Generator output from
|
|
94
|
+
[graphql-typescript-deluxe](https://github.com/dulnan/graphql-typescript-deluxe).
|
|
95
|
+
It allows you to access all operations or fragments.
|
|
96
|
+
|
|
97
|
+
### Example in `nuxt.config.ts`
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
export default defineNuxtConfig({
|
|
101
|
+
hooks: {
|
|
102
|
+
'nuxt-graphql-middleware:build': (ctx) => {
|
|
103
|
+
const fragments = ctx.output.getFragments()
|
|
104
|
+
console.log('Collected Fragments')
|
|
105
|
+
fragments.forEach((v) => {
|
|
106
|
+
// v.node contains the FragmentDefinitionNode from 'graphql'.
|
|
107
|
+
console.log(v.node.name.value)
|
|
108
|
+
})
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
})
|
|
112
|
+
```
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Module Utils
|
|
2
|
+
|
|
3
|
+
These utils can be imported from `nuxt-graphql-middleware/utils`.
|
|
4
|
+
|
|
5
|
+
::: warning
|
|
6
|
+
|
|
7
|
+
These utils can **only** be used in other modules. Importing them in any other
|
|
8
|
+
place will not work.
|
|
9
|
+
|
|
10
|
+
:::
|
|
11
|
+
|
|
12
|
+
## `useGraphqlModuleContext()`
|
|
13
|
+
|
|
14
|
+
This util exposes the `ModuleContext` instance of `nuxt-graphql-middleware`.
|
|
15
|
+
It's the same instance also available from [hooks](/configuration/module-hooks).
|
|
16
|
+
|
|
17
|
+
### Example
|
|
18
|
+
|
|
19
|
+
In this example the module conditionally enables features based on the existance
|
|
20
|
+
of certain types and fields in the schema.
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { defineNuxtModule } from '@nuxt/kit'
|
|
24
|
+
import { useGraphqlModuleContext } from 'nuxt-graphql-middleware/utils'
|
|
25
|
+
import { isObjectType } from 'graphql'
|
|
26
|
+
|
|
27
|
+
type Feature = 'comments' | 'blog' | 'analytics'
|
|
28
|
+
|
|
29
|
+
export default defineNuxtModule({
|
|
30
|
+
meta: {
|
|
31
|
+
name: 'my-custom-module',
|
|
32
|
+
},
|
|
33
|
+
setup(_options, nuxt) {
|
|
34
|
+
const enabledFeatures: Feature[] = []
|
|
35
|
+
|
|
36
|
+
const context = useGraphqlModuleContext()
|
|
37
|
+
|
|
38
|
+
// Feature is available if this type exists.
|
|
39
|
+
if (context.schemaHasType('Comment')) {
|
|
40
|
+
enabledFeatures.push('comments')
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Feature is available if a mutation called "trackPageView" exists.
|
|
44
|
+
const Mutation = context.schemaGetType('Mutation')
|
|
45
|
+
if (isObjectType(Mutation)) {
|
|
46
|
+
const fields = Mutation.getFields()
|
|
47
|
+
if (fields.trackPageView) {
|
|
48
|
+
enabledFeatures.push('analytics')
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
```
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
# Module Options
|
|
2
|
+
|
|
3
|
+
## autoImportPatterns?
|
|
4
|
+
|
|
5
|
+
> `optional` **autoImportPatterns**: `string`[]
|
|
6
|
+
|
|
7
|
+
Defined in:
|
|
8
|
+
[options.ts:25](https://github.com/dulnan/nuxt-graphql-middleware/blob/main/src/build/types/options.ts#L25)
|
|
9
|
+
|
|
10
|
+
File glob patterns for the auto import feature.
|
|
11
|
+
|
|
12
|
+
If left empty, no documents are auto imported.
|
|
13
|
+
|
|
14
|
+
### Default
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
["**/.{gql,graphql}", "!node_modules"]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Example
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
// Load .graphql files from pages folder and from a node_modules dependency.
|
|
24
|
+
const autoImportPatterns = [
|
|
25
|
+
'./pages/**/*.graphql',
|
|
26
|
+
'node_modules/my_library/dist/**/*.graphql',
|
|
27
|
+
]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## clientCache?
|
|
33
|
+
|
|
34
|
+
> `optional` **clientCache**: `object`
|
|
35
|
+
|
|
36
|
+
Defined in:
|
|
37
|
+
[options.ts:185](https://github.com/dulnan/nuxt-graphql-middleware/blob/main/src/build/types/options.ts#L185)
|
|
38
|
+
|
|
39
|
+
Client caching configuration.
|
|
40
|
+
|
|
41
|
+
### enabled?
|
|
42
|
+
|
|
43
|
+
> `optional` **enabled**: `boolean`
|
|
44
|
+
|
|
45
|
+
Whether client caching should be enabled.
|
|
46
|
+
|
|
47
|
+
Note that if you set this to false during build, the cache will not be available
|
|
48
|
+
at all. If you intend to enable/disable it using app config at runtime, it
|
|
49
|
+
_must_ be enabled at build!
|
|
50
|
+
|
|
51
|
+
##### Default
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
false
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### maxSize?
|
|
58
|
+
|
|
59
|
+
> `optional` **maxSize**: `number`
|
|
60
|
+
|
|
61
|
+
The maximum number of cache entries.
|
|
62
|
+
|
|
63
|
+
##### Default
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
100
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## codegenConfig?
|
|
72
|
+
|
|
73
|
+
> `optional` **codegenConfig**: `GeneratorOptions`
|
|
74
|
+
|
|
75
|
+
Defined in:
|
|
76
|
+
[options.ts:142](https://github.com/dulnan/nuxt-graphql-middleware/blob/main/src/build/types/options.ts#L142)
|
|
77
|
+
|
|
78
|
+
Options for graphql-typescript-deluxe code generator.
|
|
79
|
+
|
|
80
|
+
### See
|
|
81
|
+
|
|
82
|
+
[GeneratorOptions](https://github.com/dulnan/graphql-typescript-deluxe/blob/main/src/types/options.ts#L193)
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## codegenSchemaConfig?
|
|
87
|
+
|
|
88
|
+
> `optional` **codegenSchemaConfig**: `object`
|
|
89
|
+
|
|
90
|
+
Defined in:
|
|
91
|
+
[options.ts:147](https://github.com/dulnan/nuxt-graphql-middleware/blob/main/src/build/types/options.ts#L147)
|
|
92
|
+
|
|
93
|
+
Configuration for graphql-codegen when downloading the schema.
|
|
94
|
+
|
|
95
|
+
### schemaAstConfig?
|
|
96
|
+
|
|
97
|
+
> `optional` **schemaAstConfig**: `SchemaASTConfig`
|
|
98
|
+
|
|
99
|
+
Configure how the schema.graphql file should be generated.
|
|
100
|
+
|
|
101
|
+
##### See
|
|
102
|
+
|
|
103
|
+
[SchemaASTConfig](https://github.com/dotansimha/graphql-code-generator/blob/master/packages/plugins/other/schema-ast/src/index.ts#L23)
|
|
104
|
+
|
|
105
|
+
### urlSchemaOptions?
|
|
106
|
+
|
|
107
|
+
> `optional` **urlSchemaOptions**: `UrlSchemaOptions`
|
|
108
|
+
|
|
109
|
+
Configure how the schema-ast introspection request should be made.
|
|
110
|
+
|
|
111
|
+
Usually this is where you can provide a custom authentication header:
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
const codegenSchemaConfig = {
|
|
115
|
+
urlSchemaOptions: {
|
|
116
|
+
headers: {
|
|
117
|
+
authentication: 'foobar',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
##### See
|
|
124
|
+
|
|
125
|
+
[Types.UrlSchemaOptions](https://github.com/dotansimha/graphql-code-generator/blob/master/packages/utils/plugins-helpers/src/types.ts#L82)
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## debug?
|
|
130
|
+
|
|
131
|
+
> `optional` **debug**: `boolean`
|
|
132
|
+
|
|
133
|
+
Defined in:
|
|
134
|
+
[options.ts:82](https://github.com/dulnan/nuxt-graphql-middleware/blob/main/src/build/types/options.ts#L82)
|
|
135
|
+
|
|
136
|
+
Enable detailled debugging messages.
|
|
137
|
+
|
|
138
|
+
### Default
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
false
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## devtools?
|
|
147
|
+
|
|
148
|
+
> `optional` **devtools**: `boolean`
|
|
149
|
+
|
|
150
|
+
Defined in:
|
|
151
|
+
[options.ts:180](https://github.com/dulnan/nuxt-graphql-middleware/blob/main/src/build/types/options.ts#L180)
|
|
152
|
+
|
|
153
|
+
Enable Nuxt DevTools integration.
|
|
154
|
+
|
|
155
|
+
### Default
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
true
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## documents?
|
|
164
|
+
|
|
165
|
+
> `optional` **documents**: `string`[]
|
|
166
|
+
|
|
167
|
+
Defined in:
|
|
168
|
+
[options.ts:56](https://github.com/dulnan/nuxt-graphql-middleware/blob/main/src/build/types/options.ts#L56)
|
|
169
|
+
|
|
170
|
+
Additional raw documents to include.
|
|
171
|
+
|
|
172
|
+
Useful if for example you need to generate queries during build time.
|
|
173
|
+
|
|
174
|
+
### Default
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
;[]
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Example
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
const documents = [
|
|
184
|
+
`
|
|
185
|
+
query myQuery {
|
|
186
|
+
articles {
|
|
187
|
+
title
|
|
188
|
+
id
|
|
189
|
+
}
|
|
190
|
+
}`,
|
|
191
|
+
...getGeneratedDocuments(),
|
|
192
|
+
]
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## downloadSchema?
|
|
198
|
+
|
|
199
|
+
> `optional` **downloadSchema**: `boolean`
|
|
200
|
+
|
|
201
|
+
Defined in:
|
|
202
|
+
[options.ts:108](https://github.com/dulnan/nuxt-graphql-middleware/blob/main/src/build/types/options.ts#L108)
|
|
203
|
+
|
|
204
|
+
Download the GraphQL schema and store it on disk.
|
|
205
|
+
|
|
206
|
+
Usually you'll want to only enable this during dev mode.
|
|
207
|
+
|
|
208
|
+
### Default
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
true
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## enableFileUploads?
|
|
217
|
+
|
|
218
|
+
> `optional` **enableFileUploads**: `boolean`
|
|
219
|
+
|
|
220
|
+
Defined in:
|
|
221
|
+
[options.ts:75](https://github.com/dulnan/nuxt-graphql-middleware/blob/main/src/build/types/options.ts#L75)
|
|
222
|
+
|
|
223
|
+
Enable support for uploading files via GraphQL.
|
|
224
|
+
|
|
225
|
+
When enabled, an additional `useGraphqlUploadMutation` composable is included,
|
|
226
|
+
in addition to a new server endpoint that handles multi part file uploads for
|
|
227
|
+
GraphQL mutations.
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## errorOverlay?
|
|
232
|
+
|
|
233
|
+
> `optional` **errorOverlay**: `boolean`
|
|
234
|
+
|
|
235
|
+
Defined in:
|
|
236
|
+
[options.ts:87](https://github.com/dulnan/nuxt-graphql-middleware/blob/main/src/build/types/options.ts#L87)
|
|
237
|
+
|
|
238
|
+
Displays GraphQL response errors in an overlay in dev mode.
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## experimental?
|
|
243
|
+
|
|
244
|
+
> `optional` **experimental**: `object`
|
|
245
|
+
|
|
246
|
+
Defined in:
|
|
247
|
+
[options.ts:208](https://github.com/dulnan/nuxt-graphql-middleware/blob/main/src/build/types/options.ts#L208)
|
|
248
|
+
|
|
249
|
+
Experimental features.
|
|
250
|
+
|
|
251
|
+
### improvedQueryParamEncoding?
|
|
252
|
+
|
|
253
|
+
> `optional` **improvedQueryParamEncoding**: `boolean`
|
|
254
|
+
|
|
255
|
+
Enables improved encoding for GraphQL query param encoding.
|
|
256
|
+
|
|
257
|
+
If enabled, query variables that are non-strings such as numbers or booleans are
|
|
258
|
+
encoded as strings, with a prefix in their name to indicate the type.
|
|
259
|
+
|
|
260
|
+
For example, given this object definining query variables:
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
{
|
|
264
|
+
name: 'John',
|
|
265
|
+
age: 35,
|
|
266
|
+
isUser: false
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
This would be encoded as:
|
|
271
|
+
|
|
272
|
+
```
|
|
273
|
+
name=John&n:age=35&b:isUser=false
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
This only works for flat primitive values. Nested objects or arrays are still
|
|
277
|
+
encoded using the \_\_variables fallback where all variables are JSON encoded.
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## graphqlConfigFilePath?
|
|
282
|
+
|
|
283
|
+
> `optional` **graphqlConfigFilePath**: `string`
|
|
284
|
+
|
|
285
|
+
Defined in:
|
|
286
|
+
[options.ts:34](https://github.com/dulnan/nuxt-graphql-middleware/blob/main/src/build/types/options.ts#L34)
|
|
287
|
+
|
|
288
|
+
The path where your graphql.config.ts is, relative to the location of
|
|
289
|
+
nuxt.config.ts.
|
|
290
|
+
|
|
291
|
+
Used to generate the correct paths in the graphql.config.ts file generated by
|
|
292
|
+
the module.
|
|
293
|
+
|
|
294
|
+
### Default
|
|
295
|
+
|
|
296
|
+
```ts
|
|
297
|
+
'./graphql.config.ts'
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## graphqlEndpoint?
|
|
303
|
+
|
|
304
|
+
> `optional` **graphqlEndpoint**: `string`
|
|
305
|
+
|
|
306
|
+
Defined in:
|
|
307
|
+
[options.ts:99](https://github.com/dulnan/nuxt-graphql-middleware/blob/main/src/build/types/options.ts#L99)
|
|
308
|
+
|
|
309
|
+
The URL of the GraphQL server.
|
|
310
|
+
|
|
311
|
+
If not provided, the module will use the
|
|
312
|
+
NUXT_GRAPHQL_MIDDLEWARE_GRAPHQL_ENDPOINT environment variable during dev mode.
|
|
313
|
+
|
|
314
|
+
For the runtime execution you can provide a method that determines the endpoint
|
|
315
|
+
during runtime. See the server/graphqlMiddleware.serverOptions.ts documentation
|
|
316
|
+
for more information.
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
## includeComposables?
|
|
321
|
+
|
|
322
|
+
> `optional` **includeComposables**: `boolean`
|
|
323
|
+
|
|
324
|
+
Defined in:
|
|
325
|
+
[options.ts:66](https://github.com/dulnan/nuxt-graphql-middleware/blob/main/src/build/types/options.ts#L66)
|
|
326
|
+
|
|
327
|
+
Wether the useGraphqlQuery, useGraphqlMutation and useGraphqlState composables
|
|
328
|
+
should be included.
|
|
329
|
+
|
|
330
|
+
### Default
|
|
331
|
+
|
|
332
|
+
```ts
|
|
333
|
+
true
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## logOnlyErrors?
|
|
339
|
+
|
|
340
|
+
> `optional` **logOnlyErrors**: `boolean`
|
|
341
|
+
|
|
342
|
+
Defined in:
|
|
343
|
+
[options.ts:135](https://github.com/dulnan/nuxt-graphql-middleware/blob/main/src/build/types/options.ts#L135)
|
|
344
|
+
|
|
345
|
+
Logs only errors.
|
|
346
|
+
|
|
347
|
+
When enabled only errors are logged to the console when generating the GraphQL
|
|
348
|
+
operations. If false, all operations are logged, including valid ones.
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
## schemaPath?
|
|
353
|
+
|
|
354
|
+
> `optional` **schemaPath**: `string`
|
|
355
|
+
|
|
356
|
+
Defined in:
|
|
357
|
+
[options.ts:118](https://github.com/dulnan/nuxt-graphql-middleware/blob/main/src/build/types/options.ts#L118)
|
|
358
|
+
|
|
359
|
+
Path to the GraphQL schema file.
|
|
360
|
+
|
|
361
|
+
If `downloadSchema` is `true`, the downloaded schema is written to this
|
|
362
|
+
specified path. If `downloadSchema` is `false`, this file must be present in
|
|
363
|
+
order to generate types.
|
|
364
|
+
|
|
365
|
+
### Default
|
|
366
|
+
|
|
367
|
+
```ts
|
|
368
|
+
'./schema.graphql'
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
## mcp?
|
|
374
|
+
|
|
375
|
+
> `optional` **mcp**: `object`
|
|
376
|
+
|
|
377
|
+
Defined in:
|
|
378
|
+
[options.ts:242](https://github.com/dulnan/nuxt-graphql-middleware/blob/main/src/build/types/options.ts#L242)
|
|
379
|
+
|
|
380
|
+
Configuration for the @nuxtjs/mcp-toolkit integration.
|
|
381
|
+
|
|
382
|
+
### enabled
|
|
383
|
+
|
|
384
|
+
> **enabled**: `boolean`
|
|
385
|
+
|
|
386
|
+
Whether the MCP integration should be enabled.
|
|
387
|
+
|
|
388
|
+
### route?
|
|
389
|
+
|
|
390
|
+
> `optional` **route**: `string`
|
|
391
|
+
|
|
392
|
+
The route of the MCP server.
|
|
393
|
+
|
|
394
|
+
##### Default
|
|
395
|
+
|
|
396
|
+
```ts
|
|
397
|
+
'/mcp/nuxt-graphql-middleware'
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## serverApiPrefix?
|
|
403
|
+
|
|
404
|
+
> `optional` **serverApiPrefix**: `string`
|
|
405
|
+
|
|
406
|
+
Defined in:
|
|
407
|
+
[options.ts:127](https://github.com/dulnan/nuxt-graphql-middleware/blob/main/src/build/types/options.ts#L127)
|
|
408
|
+
|
|
409
|
+
The prefix for the server route.
|
|
410
|
+
|
|
411
|
+
### Default
|
|
412
|
+
|
|
413
|
+
```ts
|
|
414
|
+
'/api/graphql_middleware'
|
|
415
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Runtime Config
|
|
2
|
+
|
|
3
|
+
The following
|
|
4
|
+
[runtime config](https://nuxt.com/docs/4.x/guide/going-further/runtime-config)
|
|
5
|
+
are provided by the module:
|
|
6
|
+
|
|
7
|
+
## GraphQL Endpoint
|
|
8
|
+
|
|
9
|
+
Allows you to set or override the
|
|
10
|
+
[`graphqlEndpoint`](/configuration/module#graphqlendpoint) option.
|
|
11
|
+
|
|
12
|
+
You can set the GraphQL endpoint to use by setting the
|
|
13
|
+
`NUXT_GRAPHQL_MIDDLEWARE_GRAPHQL_ENDPOINT` environment variable:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
NUXT_GRAPHQL_MIDDLEWARE_GRAPHQL_ENDPOINT=http://example.com/graphql
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This is used to _download the schema_ in **dev mode**. A
|
|
20
|
+
[`graphqlEndpoint`](/configuration/server-options#graphqlendpoint) method
|
|
21
|
+
provided by your server options will take precedence when _making GraphQL
|
|
22
|
+
queries_. If no method exists, then the value of the environment variable is
|
|
23
|
+
also used at runtime (e.g. running the Nuxt build).
|