File tree Expand file tree Collapse file tree 4 files changed +31
-4
lines changed
docs/content/1.getting-started Expand file tree Collapse file tree 4 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -283,3 +283,22 @@ Configuration for the token storage.
283283 }
284284}
285285```
286+
287+ ### ` fetchOptions `
288+
289+ Specify additional fetch options to configure the GraphQL client.
290+
291+ [ More information here] ( https://github.com/jasonkuhrt/graphql-request#configuration )
292+
293+ ``` ts
294+ ' graphql-client' : {
295+ clients: {
296+ default: {
297+ host: ' <graphql_api>' ,
298+ fetchOptions: {
299+ errorPolicy: ' ignore' // Ignore incoming errors and resolve like no errors occurred
300+ }
301+ }
302+ }
303+ }
304+ ```
Original file line number Diff line number Diff line change @@ -22,6 +22,6 @@ export default defineNitroPlugin(() => {
2222 ...( conf ?. token ?. value && { [ tokenName ] : authToken } )
2323 }
2424
25- GqlNitro . clients [ client ] = new GraphQLClient ( conf . host , { headers } )
25+ GqlNitro . clients [ client ] = new GraphQLClient ( conf . host , { headers, ... conf . fetchOptions } )
2626 }
2727} )
Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ export default defineNuxtPlugin((nuxtApp) => {
4545 ...serverHeaders ,
4646 ...( proxyCookie && { cookie : requestHeaders ?. cookie } )
4747 } ,
48- ...v ?. corsOptions
48+ ...v ?. corsOptions ,
49+ ...v ?. fetchOptions ,
4950 }
5051
5152 nuxtApp . _gqlState . value [ name ] = {
@@ -97,7 +98,8 @@ export default defineNuxtPlugin((nuxtApp) => {
9798
9899 if ( reqOpts ?. token ) { delete reqOpts . token }
99100 return defu ( req , reqOpts )
100- }
101+ } ,
102+ ...v ?. fetchOptions ,
101103 } )
102104 }
103105 }
Original file line number Diff line number Diff line change 1- import type { GraphQLClient } from 'graphql-request'
1+ import type { GraphQLClient , FetchOptions } from 'graphql-request'
22import type { GraphQLError } from 'graphql-request/dist/types'
33import type { CookieOptions } from 'nuxt/dist/app/composables'
44
@@ -127,6 +127,12 @@ export interface GqlClient<T = string> {
127127 * Declare headers that should only be applied to the GraphQL Code Generator.
128128 * */
129129 codegenHeaders ?: Record < string , string >
130+
131+ /**
132+ * Additional fetch options to be passed to the GraphQL client.
133+ * @see https://github.com/jasonkuhrt/graphql-request#configuration
134+ */
135+ fetchOptions ?: FetchOptions
130136}
131137
132138export interface GqlCodegen {
You can’t perform that action at this time.
0 commit comments