Skip to content

Commit b0861dd

Browse files
AustioAkryum
authored andcommitted
feat: add global prefetch apollo provider option (#710)
1 parent faba677 commit b0861dd

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

docs/api/apollo-provider.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const apolloProvider = new VueApollo({
3333
console.log('Global error handler')
3434
console.error(error)
3535
},
36+
// Globally turn off prefetch ssr
37+
prefetch: Boolean
3638
})
3739
```
3840

src/apollo-provider.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export class ApolloProvider {
88
this.defaultOptions = options.defaultOptions
99
this.watchLoading = options.watchLoading
1010
this.errorHandler = options.errorHandler
11+
this.prefetch = options.prefetch
1112

1213
this.prefetchQueries = []
1314
}

src/mixin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function launch () {
9393
const smart = this.$apollo.addSmartQuery(key, options)
9494
if (this.$isServer) {
9595
options = reapply(options, this)
96-
if (options.prefetch !== false && apollo.$prefetch !== false && !smart.skip) {
96+
if (apolloProvider.prefetch !== false && options.prefetch !== false && apollo.$prefetch !== false && !smart.skip) {
9797
this.$_apolloPromises.push(smart.firstRun)
9898
}
9999
}

0 commit comments

Comments
 (0)