fix(smart apollo): ensure SmartQuery variables still function when watched expression evaluated (#1161), closes #991

This commit is contained in:
Guillaume Chau
2021-09-20 18:19:43 +02:00
parent f4e2a14bba
commit b67ff78d6a
+12 -4
View File
@@ -112,10 +112,18 @@ export default class SmartApollo {
cb = this.options.throttle ? throttle(cb, this.options.throttle) : cb
cb = this.options.debounce ? debounce(cb, this.options.debounce) : cb
}
this._watchers.push(this.vm.$watch(() => this.options.variables.call(this.vm), cb, {
immediate: true,
deep: this.options.deep,
}))
this._watchers.push(
this.vm.$watch(
() => typeof this.options.variables === 'function'
? this.options.variables.call(this.vm)
: this.options.variables,
cb,
{
immediate: true,
deep: this.options.deep,
},
),
)
} else {
this.executeApollo(this.options.variables)
}