Skip to content

Commit d841455

Browse files
author
Guillaume Chau
committed
chore: v3.0.0-beta.30
1 parent 6817321 commit d841455

File tree

4 files changed

+66
-24
lines changed

4 files changed

+66
-24
lines changed

dist/vue-apollo.esm.js

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -743,10 +743,12 @@ function (_SmartApollo) {
743743

744744
_defineProperty(_assertThisInitialized(_this), "_loading", false);
745745

746-
_this.firstRun = new Promise(function (resolve, reject) {
747-
_this._firstRunResolve = resolve;
748-
_this._firstRunReject = reject;
749-
});
746+
if (vm.$isServer) {
747+
_this.firstRun = new Promise(function (resolve, reject) {
748+
_this._firstRunResolve = resolve;
749+
_this._firstRunReject = reject;
750+
});
751+
}
750752

751753
if (_this.vm.$isServer) {
752754
_this.options.fetchPolicy = 'network-only';
@@ -1044,9 +1046,9 @@ function (_SmartApollo) {
10441046
}
10451047
}, {
10461048
key: "firstRunReject",
1047-
value: function firstRunReject() {
1049+
value: function firstRunReject(error) {
10481050
if (this._firstRunReject) {
1049-
this._firstRunReject();
1051+
this._firstRunReject(error);
10501052

10511053
this._firstRunReject = null;
10521054
}
@@ -4596,6 +4598,12 @@ var CApolloQuery = {
45964598
type: Object,
45974599
"default": undefined
45984600
},
4601+
update: {
4602+
type: Function,
4603+
"default": function _default(data) {
4604+
return data;
4605+
}
4606+
},
45994607
skip: {
46004608
type: Boolean,
46014609
"default": false
@@ -4651,6 +4659,9 @@ var CApolloQuery = {
46514659
this.$apollo.queries.query.setOptions({
46524660
notifyOnNetworkStatusChange: value
46534661
});
4662+
},
4663+
'$data.$apolloData.loading': function $data$apolloDataLoading(value) {
4664+
this.$emit('loading', !!value);
46544665
}
46554666
},
46564667
apollo: {
@@ -4708,8 +4719,10 @@ var CApolloQuery = {
47084719
this.$_previousData = _result.data;
47094720
}
47104721

4722+
var dataNotEmpty = isDataFilled(data);
47114723
this.result = {
4712-
data: isDataFilled(data) ? data : undefined,
4724+
data: dataNotEmpty ? this.update(data) : undefined,
4725+
fullData: dataNotEmpty ? data : undefined,
47134726
loading: loading,
47144727
error: error,
47154728
networkStatus: networkStatus
@@ -4850,6 +4863,11 @@ var CApolloMutation = {
48504863
error: null
48514864
};
48524865
},
4866+
watch: {
4867+
loading: function loading(value) {
4868+
this.$emit('loading', value);
4869+
}
4870+
},
48534871
methods: {
48544872
mutate: function mutate(options) {
48554873
var _this = this;
@@ -4999,10 +5017,13 @@ function launch() {
49995017
if (key.charAt(0) !== '$') {
50005018
var options = apollo[key];
50015019
var smart = this.$apollo.addSmartQuery(key, options);
5002-
options = utils_5(options, this);
50035020

5004-
if (options.prefetch !== false && apollo.$prefetch !== false && !smart.skip) {
5005-
this.$_apolloPromises.push(smart.firstRun);
5021+
if (this.$isServer) {
5022+
options = utils_5(options, this);
5023+
5024+
if (options.prefetch !== false && apollo.$prefetch !== false && !smart.skip) {
5025+
this.$_apolloPromises.push(smart.firstRun);
5026+
}
50065027
}
50075028
}
50085029
}
@@ -5111,7 +5132,7 @@ function install(Vue, options) {
51115132
}
51125133
ApolloProvider.install = install; // eslint-disable-next-line no-undef
51135134

5114-
ApolloProvider.version = "3.0.0-beta.29"; // Apollo provider
5135+
ApolloProvider.version = "3.0.0-beta.30"; // Apollo provider
51155136

51165137
var ApolloProvider$1 = ApolloProvider; // Components
51175138

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: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -749,10 +749,12 @@
749749

750750
_defineProperty(_assertThisInitialized(_this), "_loading", false);
751751

752-
_this.firstRun = new Promise(function (resolve, reject) {
753-
_this._firstRunResolve = resolve;
754-
_this._firstRunReject = reject;
755-
});
752+
if (vm.$isServer) {
753+
_this.firstRun = new Promise(function (resolve, reject) {
754+
_this._firstRunResolve = resolve;
755+
_this._firstRunReject = reject;
756+
});
757+
}
756758

757759
if (_this.vm.$isServer) {
758760
_this.options.fetchPolicy = 'network-only';
@@ -1050,9 +1052,9 @@
10501052
}
10511053
}, {
10521054
key: "firstRunReject",
1053-
value: function firstRunReject() {
1055+
value: function firstRunReject(error) {
10541056
if (this._firstRunReject) {
1055-
this._firstRunReject();
1057+
this._firstRunReject(error);
10561058

10571059
this._firstRunReject = null;
10581060
}
@@ -4602,6 +4604,12 @@
46024604
type: Object,
46034605
"default": undefined
46044606
},
4607+
update: {
4608+
type: Function,
4609+
"default": function _default(data) {
4610+
return data;
4611+
}
4612+
},
46054613
skip: {
46064614
type: Boolean,
46074615
"default": false
@@ -4657,6 +4665,9 @@
46574665
this.$apollo.queries.query.setOptions({
46584666
notifyOnNetworkStatusChange: value
46594667
});
4668+
},
4669+
'$data.$apolloData.loading': function $data$apolloDataLoading(value) {
4670+
this.$emit('loading', !!value);
46604671
}
46614672
},
46624673
apollo: {
@@ -4714,8 +4725,10 @@
47144725
this.$_previousData = _result.data;
47154726
}
47164727

4728+
var dataNotEmpty = isDataFilled(data);
47174729
this.result = {
4718-
data: isDataFilled(data) ? data : undefined,
4730+
data: dataNotEmpty ? this.update(data) : undefined,
4731+
fullData: dataNotEmpty ? data : undefined,
47194732
loading: loading,
47204733
error: error,
47214734
networkStatus: networkStatus
@@ -4856,6 +4869,11 @@
48564869
error: null
48574870
};
48584871
},
4872+
watch: {
4873+
loading: function loading(value) {
4874+
this.$emit('loading', value);
4875+
}
4876+
},
48594877
methods: {
48604878
mutate: function mutate(options) {
48614879
var _this = this;
@@ -5005,10 +5023,13 @@
50055023
if (key.charAt(0) !== '$') {
50065024
var options = apollo[key];
50075025
var smart = this.$apollo.addSmartQuery(key, options);
5008-
options = utils_5(options, this);
50095026

5010-
if (options.prefetch !== false && apollo.$prefetch !== false && !smart.skip) {
5011-
this.$_apolloPromises.push(smart.firstRun);
5027+
if (this.$isServer) {
5028+
options = utils_5(options, this);
5029+
5030+
if (options.prefetch !== false && apollo.$prefetch !== false && !smart.skip) {
5031+
this.$_apolloPromises.push(smart.firstRun);
5032+
}
50125033
}
50135034
}
50145035
}
@@ -5117,7 +5138,7 @@
51175138
}
51185139
ApolloProvider.install = install; // eslint-disable-next-line no-undef
51195140

5120-
ApolloProvider.version = "3.0.0-beta.29"; // Apollo provider
5141+
ApolloProvider.version = "3.0.0-beta.30"; // Apollo provider
51215142

51225143
var ApolloProvider$1 = ApolloProvider; // Components
51235144

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-apollo",
3-
"version": "3.0.0-beta.29",
3+
"version": "3.0.0-beta.30",
44
"description": "Use Apollo and GraphQL with Vue.js",
55
"main": "dist/vue-apollo.umd.js",
66
"module": "dist/vue-apollo.esm.js",

0 commit comments

Comments
 (0)