Skip to content

Commit d168c20

Browse files
fix(smart apollo): ensure SmartQuery variables still function when watched expression evaluated (#1161)
Co-authored-by: Daniel Small <[email protected]>
1 parent 1268980 commit d168c20

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,19 @@ export default class SmartApollo {
112112
cb = this.options.throttle ? throttle(cb, this.options.throttle) : cb
113113
cb = this.options.debounce ? debounce(cb, this.options.debounce) : cb
114114
}
115-
this._watchers.push(this.vm.$watch(() => this.options.variables.call(this.vm), cb, {
116-
immediate: true,
117-
deep: this.options.deep,
118-
}))
115+
116+
this._watchers.push(
117+
this.vm.$watch(
118+
() => typeof this.options.variables === 'function'
119+
? this.options.variables.call(this.vm)
120+
: this.options.variables,
121+
cb,
122+
{
123+
immediate: true,
124+
deep: this.options.deep,
125+
}
126+
)
127+
)
119128
} else {
120129
this.executeApollo(this.options.variables)
121130
}

0 commit comments

Comments
 (0)