Skip to content

Commit be7ad37

Browse files
author
Guillaume Chau
committed
Merge remote-tracking branch 'origin/master'
2 parents f6207da + 8dbcadd commit be7ad37

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,8 @@ On the queries you want to prefetch on the server, add the `prefetch` option. It
11681168
- a variables object,
11691169
- a function that gets the context object (which can contain the URL for example) and return a variables object,
11701170
- `true` (query's `variables` is reused).
1171+
1172+
If you are returning a variables object in the `prefetch` option make sure it matches with the result of the `variables` option. If they do not match the query's data property will not be populated while rendering the template server-side.
11711173

11721174
**Warning! You don't have access to the component instance when doing prefetching on the server. Don't use `this` in `prefetch`!**
11731175

dist/vue-apollo.esm.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2961,9 +2961,15 @@ var SmartSubscription = function (_SmartApollo2) {
29612961
createClass(SmartSubscription, [{
29622962
key: 'executeApollo',
29632963
value: function executeApollo(variables) {
2964+
var variablesJson = JSON.stringify(variables);
29642965
if (this.sub) {
2966+
// do nothing if subscription is already running using exactly the same variables
2967+
if (variablesJson === this.previousVariablesJson) {
2968+
return;
2969+
}
29652970
this.sub.unsubscribe();
29662971
}
2972+
this.previousVariablesJson = variablesJson;
29672973

29682974
var apolloOptions = this.generateApolloOptions(variables);
29692975

dist/vue-apollo.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-apollo.umd.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2967,9 +2967,15 @@ var SmartSubscription = function (_SmartApollo2) {
29672967
createClass(SmartSubscription, [{
29682968
key: 'executeApollo',
29692969
value: function executeApollo(variables) {
2970+
var variablesJson = JSON.stringify(variables);
29702971
if (this.sub) {
2972+
// do nothing if subscription is already running using exactly the same variables
2973+
if (variablesJson === this.previousVariablesJson) {
2974+
return;
2975+
}
29712976
this.sub.unsubscribe();
29722977
}
2978+
this.previousVariablesJson = variablesJson;
29732979

29742980
var apolloOptions = this.generateApolloOptions(variables);
29752981

src/smart-apollo.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,15 @@ export class SmartSubscription extends SmartApollo {
344344
]
345345

346346
executeApollo (variables) {
347+
const variablesJson = JSON.stringify(variables)
347348
if (this.sub) {
349+
// do nothing if subscription is already running using exactly the same variables
350+
if (variablesJson === this.previousVariablesJson) {
351+
return
352+
}
348353
this.sub.unsubscribe()
349354
}
355+
this.previousVariablesJson = variablesJson
350356

351357
const apolloOptions = this.generateApolloOptions(variables)
352358

0 commit comments

Comments
 (0)