Skip to content

Commit 255d8f5

Browse files
committed
fix: subs error handling, closes #877
1 parent b6e8ec3 commit 255d8f5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ export default class SmartSubscription extends SmartApollo {
1919
}
2020
}
2121

22+
generateApolloOptions (variables) {
23+
const apolloOptions = super.generateApolloOptions(variables)
24+
25+
apolloOptions.onError = this.catchError.bind(this)
26+
27+
return apolloOptions
28+
}
29+
2230
executeApollo (variables) {
2331
const variablesJson = JSON.stringify(variables)
2432
if (this.sub) {
@@ -67,4 +75,13 @@ export default class SmartSubscription extends SmartApollo {
6775
this.options.result.call(this.vm, data, this.key)
6876
}
6977
}
78+
79+
catchError (error) {
80+
super.catchError(error)
81+
// Restart the subscription
82+
if (!this.skip) {
83+
this.stop()
84+
this.start()
85+
}
86+
}
7087
}

0 commit comments

Comments
 (0)