@@ -41,7 +41,7 @@ export default defineNuxtModule<ModuleOptions>({
41
41
} ,
42
42
clientAwareness : false
43
43
} ,
44
- async setup ( options , nuxt ) {
44
+ async setup ( options , nuxt ) {
45
45
if ( ! options . clients || ! Object . keys ( options . clients ) . length ) {
46
46
logger . warn ( 'No apollo clients configured.' )
47
47
return
@@ -62,7 +62,7 @@ export default defineNuxtModule<ModuleOptions>({
62
62
const clients : Record < string , ClientConfig > = { }
63
63
const configPaths : Record < string , string > = { }
64
64
65
- async function prepareClients ( ) {
65
+ async function prepareClients ( ) {
66
66
// eslint-disable-next-line prefer-const
67
67
for ( let [ k , v ] of Object . entries ( options . clients || { } ) ) {
68
68
if ( typeof v === 'string' ) {
@@ -75,14 +75,18 @@ export default defineNuxtModule<ModuleOptions>({
75
75
}
76
76
77
77
v = resolvedConfig
78
- if ( ! configPaths [ k ] ) { configPaths [ k ] = path }
78
+ if ( ! configPaths [ k ] ) {
79
+ configPaths [ k ] = path
80
+ }
79
81
}
80
82
81
83
v . authType = ( v ?. authType === undefined ? options . authType : v ?. authType ) || null
82
84
v . authHeader = v ?. authHeader || options . authHeader
83
85
v . tokenName = v ?. tokenName || `apollo:${ k } .token`
84
86
v . tokenStorage = v ?. tokenStorage || options . tokenStorage
85
- if ( v . cookieAttributes ) { v . cookieAttributes = defu ( v ?. cookieAttributes , options . cookieAttributes ) }
87
+ if ( v . cookieAttributes ) {
88
+ v . cookieAttributes = defu ( v ?. cookieAttributes , options . cookieAttributes )
89
+ }
86
90
87
91
v . defaultOptions = v ?. defaultOptions || options . defaultOptions
88
92
@@ -163,15 +167,19 @@ export default defineNuxtModule<ModuleOptions>({
163
167
config . plugins = config . plugins || [ ]
164
168
config . plugins . push ( GraphQLPlugin ( ) as PluginOption )
165
169
166
- if ( ! nuxt . options . dev ) { config . define = { ...config . define , __DEV__ : false } }
170
+ if ( ! nuxt . options . dev ) {
171
+ config . define = { ...config . define , __DEV__ : false }
172
+ }
167
173
} )
168
174
169
175
nuxt . hook ( 'webpack:config' , ( configs ) => {
170
176
for ( const config of configs ) {
171
177
// eslint-disable-next-line @typescript-eslint/no-explicit-any
172
178
const hasGqlLoader = config . module . rules . some ( ( rule : any ) => rule ?. use === 'graphql-tag/loader' )
173
179
174
- if ( hasGqlLoader ) { return }
180
+ if ( hasGqlLoader ) {
181
+ return
182
+ }
175
183
176
184
config . module . rules . push ( {
177
185
test : / \. ( g r a p h q l | g q l ) $ / ,
@@ -182,7 +190,9 @@ export default defineNuxtModule<ModuleOptions>({
182
190
} )
183
191
184
192
nuxt . hook ( 'builder:watch' , async ( _event , path ) => {
185
- if ( ! Object . values ( configPaths ) . some ( p => p . includes ( path ) ) ) { return }
193
+ if ( ! Object . values ( configPaths ) . some ( p => p . includes ( path ) ) ) {
194
+ return
195
+ }
186
196
187
197
logger . log ( '[@nuxtjs/apollo] Reloading Apollo configuration' )
188
198
0 commit comments