Skip to content

Commit b6e8ec3

Browse files
committed
fix: handle initial skip all values
1 parent 029d934 commit b6e8ec3

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

packages/vue-apollo/src/dollar-apollo.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,15 @@ export class DollarApollo {
169169

170170
// eslint-disable-next-line accessor-pairs
171171
set skipAllQueries (value) {
172+
this._skipAllQueries = value
172173
for (const key in this.queries) {
173174
this.queries[key].skip = value
174175
}
175176
}
176177

177178
// eslint-disable-next-line accessor-pairs
178179
set skipAllSubscriptions (value) {
180+
this._skipAllSubscriptions = value
179181
for (const key in this.subscriptions) {
180182
this.subscriptions[key].skip = value
181183
}

packages/vue-apollo/src/smart-apollo.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import { throttle, debounce, omit, addGqlError } from '../lib/utils'
22

3+
const skippAllKeys = {
4+
query: '_skipAllQueries',
5+
subscription: '_skipAllSubscriptions',
6+
}
7+
38
export default class SmartApollo {
49
type = null
510
vueApolloSpecialKeys = []
611

7-
constructor (vm, key, options, autostart = true) {
12+
constructor (vm, key, options) {
813
this.vm = vm
914
this.key = key
1015
this.initialOptions = options
@@ -14,10 +19,6 @@ export default class SmartApollo {
1419
this._watchers = []
1520
this._destroyed = false
1621
this.lastApolloOptions = null
17-
18-
if (autostart) {
19-
this.autostart()
20-
}
2122
}
2223

2324
autostart () {
@@ -26,7 +27,7 @@ export default class SmartApollo {
2627
immediate: true,
2728
deep: this.options.deep,
2829
})
29-
} else if (!this.options.skip) {
30+
} else if (!this.options.skip && !this.allSkip) {
3031
this.start()
3132
} else {
3233
this._skip = true
@@ -68,14 +69,18 @@ export default class SmartApollo {
6869
}
6970

7071
set skip (value) {
71-
if (value) {
72+
if (value || this.allSkip) {
7273
this.stop()
7374
} else {
7475
this.start()
7576
}
7677
this._skip = value
7778
}
7879

80+
get allSkip () {
81+
return this.vm.$apollo[skippAllKeys[this.type]]
82+
}
83+
7984
refresh () {
8085
if (!this._skip) {
8186
this.stop()

packages/vue-apollo/src/smart-query.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default class SmartQuery extends SmartApollo {
1515
})
1616
}
1717

18-
super(vm, key, options, false)
18+
super(vm, key, options)
1919

2020
if (vm.$isServer) {
2121
this.firstRun = new Promise((resolve, reject) => {

packages/vue-apollo/src/smart-subscription.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ export default class SmartSubscription extends SmartApollo {
1111
'linkedQuery',
1212
]
1313

14+
constructor (vm, key, options, autostart = true) {
15+
super(vm, key, options)
16+
17+
if (autostart) {
18+
this.autostart()
19+
}
20+
}
21+
1422
executeApollo (variables) {
1523
const variablesJson = JSON.stringify(variables)
1624
if (this.sub) {

0 commit comments

Comments
 (0)