fix: uncaught in promise on client-side, closes #572
This commit is contained in:
+5
-3
@@ -91,9 +91,11 @@ function launch () {
|
||||
if (key.charAt(0) !== '$') {
|
||||
let options = apollo[key]
|
||||
const smart = this.$apollo.addSmartQuery(key, options)
|
||||
options = reapply(options, this)
|
||||
if (options.prefetch !== false && apollo.$prefetch !== false && !smart.skip) {
|
||||
this.$_apolloPromises.push(smart.firstRun)
|
||||
if (this.$isServer) {
|
||||
options = reapply(options, this)
|
||||
if (options.prefetch !== false && apollo.$prefetch !== false && !smart.skip) {
|
||||
this.$_apolloPromises.push(smart.firstRun)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-6
@@ -24,10 +24,12 @@ export default class SmartQuery extends SmartApollo {
|
||||
|
||||
super(vm, key, options, false)
|
||||
|
||||
this.firstRun = new Promise((resolve, reject) => {
|
||||
this._firstRunResolve = resolve
|
||||
this._firstRunReject = reject
|
||||
})
|
||||
if (vm.$isServer) {
|
||||
this.firstRun = new Promise((resolve, reject) => {
|
||||
this._firstRunResolve = resolve
|
||||
this._firstRunReject = reject
|
||||
})
|
||||
}
|
||||
|
||||
if (this.vm.$isServer) {
|
||||
this.options.fetchPolicy = 'network-only'
|
||||
@@ -291,9 +293,9 @@ export default class SmartQuery extends SmartApollo {
|
||||
}
|
||||
}
|
||||
|
||||
firstRunReject () {
|
||||
firstRunReject (error) {
|
||||
if (this._firstRunReject) {
|
||||
this._firstRunReject()
|
||||
this._firstRunReject(error)
|
||||
this._firstRunReject = null
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user