@@ -6,30 +6,6 @@ function hasProperty (holder, key) {
6
6
return typeof holder !== 'undefined' && Object . prototype . hasOwnProperty . call ( holder , key )
7
7
}
8
8
9
- function proxyData ( ) {
10
- this . $_apolloInitData = { }
11
-
12
- const apollo = this . $options . apollo
13
- if ( apollo ) {
14
- // watchQuery
15
- for ( const key in apollo ) {
16
- if ( key . charAt ( 0 ) !== '$' ) {
17
- const options = apollo [ key ]
18
- // Property proxy
19
- if ( ! options . manual && ! hasProperty ( this . $options . props , key ) && ! hasProperty ( this . $options . computed , key ) && ! hasProperty ( this . $options . methods , key ) ) {
20
- Object . defineProperty ( this , key , {
21
- get : ( ) => this . $data . $apolloData . data [ key ] ,
22
- // For component class constructor
23
- set : value => this . $_apolloInitData [ key ] = value ,
24
- enumerable : true ,
25
- configurable : true ,
26
- } )
27
- }
28
- }
29
- }
30
- }
31
- }
32
-
33
9
function launch ( ) {
34
10
const apolloProvider = this . $apolloProvider
35
11
@@ -112,18 +88,30 @@ function destroy () {
112
88
export function installMixin ( app , provider ) {
113
89
app . mixin ( {
114
90
data ( ) {
115
- return {
91
+ const result = {
116
92
$apolloData : {
117
93
queries : { } ,
118
94
loading : 0 ,
119
- data : this . $_apolloInitData ,
95
+ data : { } ,
120
96
} ,
121
97
}
98
+ // Init data props
99
+ const apollo = this . $options . apollo
100
+ if ( apollo ) {
101
+ for ( const key in apollo ) {
102
+ if ( key . charAt ( 0 ) !== '$' ) {
103
+ const options = apollo [ key ]
104
+ if ( ! options . manual && ! hasProperty ( this . $options . props , key ) && ! hasProperty ( this . $options . computed , key ) && ! hasProperty ( this . $options . methods , key ) ) {
105
+ result [ key ] = null
106
+ }
107
+ }
108
+ }
109
+ }
110
+ return result
122
111
} ,
123
112
124
113
beforeCreate ( ) {
125
114
this . $apollo = new DollarApollo ( this , provider )
126
- proxyData . call ( this )
127
115
if ( isServer ) {
128
116
// Patch render function to cleanup apollo
129
117
const render = this . $options . render
0 commit comments