nuxt-graphql-middleware 5.2.2 → 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.
Files changed (142) hide show
  1. package/README.md +2 -0
  2. package/dist/client/200.html +1 -1
  3. package/dist/client/404.html +1 -1
  4. package/dist/client/_nuxt/CqRv5mwS.js +2 -0
  5. package/dist/client/_nuxt/{DKGPmQRi.js → D95LLO0l.js} +1 -1
  6. package/dist/client/_nuxt/DZ-uq6Vd.js +1 -0
  7. package/dist/client/_nuxt/DrXVleME.js +4 -0
  8. package/dist/client/_nuxt/{CLvFsrJf.js → Dx-h1-qv.js} +1 -1
  9. package/dist/client/_nuxt/builds/latest.json +1 -1
  10. package/dist/client/_nuxt/builds/meta/f3f3372e-493e-4c8e-9dbd-18d4c5406f44.json +1 -0
  11. package/dist/client/_nuxt/{entry.DUAtNXP_.css → entry.Cyocd7ae.css} +1 -1
  12. package/dist/client/_nuxt/error-404.BLrjNXsr.css +1 -0
  13. package/dist/client/_nuxt/error-500.DLkAwcfL.css +1 -0
  14. package/dist/client/index.html +1 -1
  15. package/dist/module.d.mts +1 -1
  16. package/dist/module.json +3 -3
  17. package/dist/module.mjs +1526 -70
  18. package/dist/runtime/components/CodeFrame.d.vue.ts +8 -0
  19. package/dist/runtime/components/CodeFrame.vue.d.ts +2 -1
  20. package/dist/runtime/components/DevModeOverlay.d.vue.ts +4 -0
  21. package/dist/runtime/components/DevModeOverlay.vue +1 -1
  22. package/dist/runtime/components/DevModeOverlay.vue.d.ts +2 -1
  23. package/dist/runtime/components/ErrorExtensions.d.vue.ts +6 -0
  24. package/dist/runtime/components/ErrorExtensions.vue.d.ts +2 -1
  25. package/dist/runtime/components/ErrorGroup.d.vue.ts +10 -0
  26. package/dist/runtime/components/ErrorGroup.vue.d.ts +2 -1
  27. package/dist/runtime/css/output.css +1 -1
  28. package/dist/runtime/helpers/composables.d.ts +1 -40
  29. package/dist/runtime/helpers/composables.js +3 -12
  30. package/dist/runtime/helpers/shared-types.d.ts +40 -0
  31. package/dist/runtime/helpers/shared-types.js +12 -0
  32. package/dist/runtime/server/api/doRequest.d.ts +2 -0
  33. package/dist/runtime/server/api/doRequest.js +18 -0
  34. package/dist/runtime/server/helpers/index.js +1 -1
  35. package/dist/runtime/server/mcp/index.d.ts +2 -0
  36. package/dist/runtime/server/mcp/index.js +63 -0
  37. package/dist/runtime/server/mcp/resources/docs.d.ts +2 -0
  38. package/dist/runtime/server/mcp/resources/docs.js +36 -0
  39. package/dist/runtime/server/mcp/tools/fragments-get/index.d.ts +1 -0
  40. package/dist/runtime/server/mcp/tools/fragments-get/index.js +35 -0
  41. package/dist/runtime/server/mcp/tools/fragments-get/types.d.ts +20 -0
  42. package/dist/runtime/server/mcp/tools/fragments-get/types.js +13 -0
  43. package/dist/runtime/server/mcp/tools/fragments-get-source/index.d.ts +1 -0
  44. package/dist/runtime/server/mcp/tools/fragments-get-source/index.js +34 -0
  45. package/dist/runtime/server/mcp/tools/fragments-get-source/types.d.ts +10 -0
  46. package/dist/runtime/server/mcp/tools/fragments-get-source/types.js +9 -0
  47. package/dist/runtime/server/mcp/tools/fragments-list/index.d.ts +1 -0
  48. package/dist/runtime/server/mcp/tools/fragments-list/index.js +36 -0
  49. package/dist/runtime/server/mcp/tools/fragments-list/types.d.ts +20 -0
  50. package/dist/runtime/server/mcp/tools/fragments-list/types.js +14 -0
  51. package/dist/runtime/server/mcp/tools/fragments-list-for-type/index.d.ts +1 -0
  52. package/dist/runtime/server/mcp/tools/fragments-list-for-type/index.js +39 -0
  53. package/dist/runtime/server/mcp/tools/fragments-list-for-type/types.d.ts +31 -0
  54. package/dist/runtime/server/mcp/tools/fragments-list-for-type/types.js +23 -0
  55. package/dist/runtime/server/mcp/tools/graphql-execute/index.d.ts +1 -0
  56. package/dist/runtime/server/mcp/tools/graphql-execute/index.js +59 -0
  57. package/dist/runtime/server/mcp/tools/module-get-config/index.d.ts +1 -0
  58. package/dist/runtime/server/mcp/tools/module-get-config/index.js +23 -0
  59. package/dist/runtime/server/mcp/tools/module-get-config/types.d.ts +39 -0
  60. package/dist/runtime/server/mcp/tools/module-get-config/types.js +26 -0
  61. package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/index.d.ts +1 -0
  62. package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/index.js +36 -0
  63. package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/types.d.ts +49 -0
  64. package/dist/runtime/server/mcp/tools/nitro-graphql-server-utils-example/types.js +24 -0
  65. package/dist/runtime/server/mcp/tools/operations-execute/index.d.ts +1 -0
  66. package/dist/runtime/server/mcp/tools/operations-execute/index.js +63 -0
  67. package/dist/runtime/server/mcp/tools/operations-get/index.d.ts +1 -0
  68. package/dist/runtime/server/mcp/tools/operations-get/index.js +40 -0
  69. package/dist/runtime/server/mcp/tools/operations-get/types.d.ts +32 -0
  70. package/dist/runtime/server/mcp/tools/operations-get/types.js +18 -0
  71. package/dist/runtime/server/mcp/tools/operations-get-field-usage/index.d.ts +1 -0
  72. package/dist/runtime/server/mcp/tools/operations-get-field-usage/index.js +39 -0
  73. package/dist/runtime/server/mcp/tools/operations-get-field-usage/types.d.ts +38 -0
  74. package/dist/runtime/server/mcp/tools/operations-get-field-usage/types.js +19 -0
  75. package/dist/runtime/server/mcp/tools/operations-get-source/index.d.ts +1 -0
  76. package/dist/runtime/server/mcp/tools/operations-get-source/index.js +39 -0
  77. package/dist/runtime/server/mcp/tools/operations-get-source/types.d.ts +10 -0
  78. package/dist/runtime/server/mcp/tools/operations-get-source/types.js +9 -0
  79. package/dist/runtime/server/mcp/tools/operations-list/index.d.ts +1 -0
  80. package/dist/runtime/server/mcp/tools/operations-list/index.js +46 -0
  81. package/dist/runtime/server/mcp/tools/operations-list/types.d.ts +53 -0
  82. package/dist/runtime/server/mcp/tools/operations-list/types.js +33 -0
  83. package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/index.d.ts +1 -0
  84. package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/index.js +37 -0
  85. package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/types.d.ts +24 -0
  86. package/dist/runtime/server/mcp/tools/schema-get-interface-implementors/types.js +16 -0
  87. package/dist/runtime/server/mcp/tools/schema-get-type/index.d.ts +1 -0
  88. package/dist/runtime/server/mcp/tools/schema-get-type/index.js +31 -0
  89. package/dist/runtime/server/mcp/tools/schema-get-type/types.d.ts +112 -0
  90. package/dist/runtime/server/mcp/tools/schema-get-type/types.js +45 -0
  91. package/dist/runtime/server/mcp/tools/schema-get-type-definition/index.d.ts +1 -0
  92. package/dist/runtime/server/mcp/tools/schema-get-type-definition/index.js +33 -0
  93. package/dist/runtime/server/mcp/tools/schema-get-type-definition/types.d.ts +10 -0
  94. package/dist/runtime/server/mcp/tools/schema-get-type-definition/types.js +9 -0
  95. package/dist/runtime/server/mcp/tools/schema-get-type-usage/index.d.ts +1 -0
  96. package/dist/runtime/server/mcp/tools/schema-get-type-usage/index.js +35 -0
  97. package/dist/runtime/server/mcp/tools/schema-get-type-usage/types.d.ts +39 -0
  98. package/dist/runtime/server/mcp/tools/schema-get-type-usage/types.js +17 -0
  99. package/dist/runtime/server/mcp/tools/schema-get-union-members/index.d.ts +1 -0
  100. package/dist/runtime/server/mcp/tools/schema-get-union-members/index.js +35 -0
  101. package/dist/runtime/server/mcp/tools/schema-get-union-members/types.d.ts +24 -0
  102. package/dist/runtime/server/mcp/tools/schema-get-union-members/types.js +16 -0
  103. package/dist/runtime/server/mcp/tools/schema-list-types/index.d.ts +1 -0
  104. package/dist/runtime/server/mcp/tools/schema-list-types/index.js +37 -0
  105. package/dist/runtime/server/mcp/tools/schema-list-types/types.d.ts +53 -0
  106. package/dist/runtime/server/mcp/tools/schema-list-types/types.js +21 -0
  107. package/dist/runtime/server/mcp/tools/schema-validate-document/index.d.ts +1 -0
  108. package/dist/runtime/server/mcp/tools/schema-validate-document/index.js +31 -0
  109. package/dist/runtime/server/mcp/tools/schema-validate-document/types.d.ts +26 -0
  110. package/dist/runtime/server/mcp/tools/schema-validate-document/types.js +21 -0
  111. package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/index.d.ts +1 -0
  112. package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/index.js +36 -0
  113. package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/types.d.ts +49 -0
  114. package/dist/runtime/server/mcp/tools/vue-graphql-composable-example/types.js +24 -0
  115. package/dist/runtime/server/mcp/utils/index.d.ts +48 -0
  116. package/dist/runtime/server/mcp/utils/index.js +35 -0
  117. package/dist/runtime/server/utils/useGraphqlMutation.d.ts +1 -1
  118. package/dist/runtime/server/utils/useGraphqlMutation.js +1 -1
  119. package/dist/runtime/server/utils/useGraphqlQuery.d.ts +1 -1
  120. package/dist/runtime/server/utils/useGraphqlQuery.js +1 -1
  121. package/dist/runtime/types.d.ts +1 -1
  122. package/dist/shared/{nuxt-graphql-middleware.ct2xvPoD.d.mts → nuxt-graphql-middleware.COufMnWs.d.mts} +119 -2
  123. package/dist/utils.d.mts +1 -1
  124. package/docs/composables/useAsyncGraphqlQuery.md +313 -0
  125. package/docs/composables/useGraphqlMutation.md +29 -0
  126. package/docs/composables/useGraphqlQuery.md +73 -0
  127. package/docs/composables/useGraphqlState.md +58 -0
  128. package/docs/composables/useGraphqlUploadMutation.md +57 -0
  129. package/docs/configuration/client-options.md +121 -0
  130. package/docs/configuration/module-hooks.md +112 -0
  131. package/docs/configuration/module-utils.md +53 -0
  132. package/docs/configuration/module.md +415 -0
  133. package/docs/configuration/runtime-config.md +23 -0
  134. package/docs/configuration/server-options.md +230 -0
  135. package/package.json +102 -44
  136. package/dist/client/_nuxt/CKZE-Gmz.js +0 -2
  137. package/dist/client/_nuxt/CYCWsMRt.js +0 -1
  138. package/dist/client/_nuxt/DPP_zJIh.js +0 -25
  139. package/dist/client/_nuxt/builds/meta/1a5c6b94-502b-4ab8-a5c9-f955b10f2b06.json +0 -1
  140. package/dist/client/_nuxt/error-404.DlVPZ4GE.css +0 -1
  141. package/dist/client/_nuxt/error-500.DjyirMQI.css +0 -1
  142. package/dist/runtime/server/tsconfig.json +0 -3
@@ -0,0 +1,121 @@
1
+ # Client Options
2
+
3
+ `nuxt-graphql-middleware` will look for a file called
4
+ `graphqlMiddleware.clientOptions.ts` in your app dir. This file can export so
5
+ called "client options" which are used when _making a request to the GraphQL
6
+ middleware_.
7
+
8
+ ::: warning
9
+
10
+ Note that the client options are only used in a **Nuxt app context** - they are
11
+ not used when using `useGraphqlQuery` or other utils in a **Nitro context** such
12
+ as event handlers.
13
+
14
+ :::
15
+
16
+ ## Defining Client Options
17
+
18
+ When using a composable such as `useGraphqlQuery`, behind the scenes it will use
19
+ `$fetch` to make a request to the GraphQL middleware server route. Sometimes
20
+ it's useful to pass some additional context with this request that can then be
21
+ used on the server.
22
+
23
+ Similar to [serverOptions](/configuration/server-options), you can create a file
24
+ called `graphqlMiddleware.clientOptions.ts` in your `app` directory (usually
25
+ `<rootDir>/app`).
26
+
27
+ ::: code-group
28
+
29
+ ```typescript [~/app/graphqlMiddleware.clientOptions.ts]
30
+ import { defineGraphqlClientOptions } from 'nuxt-graphql-middleware/client-options'
31
+
32
+ export default defineGraphqlClientOptions({})
33
+ ```
34
+
35
+ :::
36
+
37
+ ## Defining Client Context
38
+
39
+ Implement the `buildClientContext()` method to return an object with string
40
+ values.
41
+
42
+ ::: code-group
43
+
44
+ ```typescript [~/app/graphqlMiddleware.clientOptions.ts]
45
+ import { defineGraphqlClientOptions } from 'nuxt-graphql-middleware/client-options'
46
+
47
+ export default defineGraphqlClientOptions<{
48
+ language: string
49
+ country: string
50
+ }>({
51
+ buildClientContext() {
52
+ const language = useCurrentLanguage()
53
+ const country = useCurrentCountry()
54
+ return {
55
+ language: language.value,
56
+ country: country.value,
57
+ }
58
+ },
59
+ })
60
+ ```
61
+
62
+ :::
63
+
64
+ ::: info
65
+
66
+ By passing a generic in `defineGraphqlClientOptions` you can define the type of
67
+ your context object.
68
+
69
+ :::
70
+
71
+ Now everytime a request to the middleware is made with a composable such as
72
+ `useGraphqlQuery`, the composable will call the `buildClientContext` method to
73
+ get the current context. It then maps each property of the returned object to a
74
+ query parameter while prefixing the property to prevent collisions with
75
+ potential query parameters from GraphQL variables.
76
+
77
+ So for example, when making a GraphQL query like so:
78
+
79
+ ```typescript
80
+ const data = await useGraphqlQuery('loadProduct', {
81
+ id: '123',
82
+ })
83
+ ```
84
+
85
+ The composable will make a fetch request to this URL.
86
+
87
+ `/api/graphql_middleware/loadProduct?id=123&__gqlc_language=en&__gqlc_country=US`
88
+
89
+ Both the `language` and `country` properties we returned in the object in
90
+ `buildClientContext()` are appended as prefixed query parameters.
91
+
92
+ ## Using Client Context
93
+
94
+ On the server you can then access this client context from within all
95
+ [serverOptions](/configuration/server-options) methods:
96
+
97
+ ::: code-group
98
+
99
+ ```typescript [~/server/graphqlMiddleware.serverOptions.ts]
100
+ import { defineGraphqlServerOptions } from 'nuxt-graphql-middleware/server-options'
101
+
102
+ export default defineGraphqlServerOptions({
103
+ graphqlEndpoint(event, operation, operationName, context) {
104
+ // Use the language from the client context.
105
+ const language = context?.client?.language || 'en'
106
+ return `http://backend_server/${language}/graphql`
107
+ },
108
+
109
+ serverFetchOptions: function (event, _operation, operationName, context) {
110
+ // Pass the current country as a header when making a request to the
111
+ // GraphQL server.
112
+ return {
113
+ headers: {
114
+ 'x-current-country': context.client?.country || 'US',
115
+ },
116
+ }
117
+ },
118
+ })
119
+ ```
120
+
121
+ :::
@@ -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).