Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Sep 14, 2017
2 parents f6207da + 8dbcadd commit be7ad37
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,8 @@ On the queries you want to prefetch on the server, add the `prefetch` option. It
- a variables object,
- a function that gets the context object (which can contain the URL for example) and return a variables object,
- `true` (query's `variables` is reused).

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.

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

Expand Down
6 changes: 6 additions & 0 deletions dist/vue-apollo.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2961,9 +2961,15 @@ var SmartSubscription = function (_SmartApollo2) {
createClass(SmartSubscription, [{
key: 'executeApollo',
value: function executeApollo(variables) {
var variablesJson = JSON.stringify(variables);
if (this.sub) {
// do nothing if subscription is already running using exactly the same variables
if (variablesJson === this.previousVariablesJson) {
return;
}
this.sub.unsubscribe();
}
this.previousVariablesJson = variablesJson;

var apolloOptions = this.generateApolloOptions(variables);

Expand Down
2 changes: 1 addition & 1 deletion dist/vue-apollo.min.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions dist/vue-apollo.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -2967,9 +2967,15 @@ var SmartSubscription = function (_SmartApollo2) {
createClass(SmartSubscription, [{
key: 'executeApollo',
value: function executeApollo(variables) {
var variablesJson = JSON.stringify(variables);
if (this.sub) {
// do nothing if subscription is already running using exactly the same variables
if (variablesJson === this.previousVariablesJson) {
return;
}
this.sub.unsubscribe();
}
this.previousVariablesJson = variablesJson;

var apolloOptions = this.generateApolloOptions(variables);

Expand Down
6 changes: 6 additions & 0 deletions src/smart-apollo.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,15 @@ export class SmartSubscription extends SmartApollo {
]

executeApollo (variables) {
const variablesJson = JSON.stringify(variables)
if (this.sub) {
// do nothing if subscription is already running using exactly the same variables
if (variablesJson === this.previousVariablesJson) {
return
}
this.sub.unsubscribe()
}
this.previousVariablesJson = variablesJson

const apolloOptions = this.generateApolloOptions(variables)

Expand Down

0 comments on commit be7ad37

Please sign in to comment.