Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,10 @@ const apolloProvider = new VueApollo({
defaultOptions: {
// apollo options applied to all components that are using apollo
$loadingKey: 'loading',
// apollo options applied to all queries in components
$query: {
fetchPolicy: 'cache-and-network'
}
},
})
```
Expand Down
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,18 @@ const launch = function launch () {
// watchQuery
for (let key in apollo) {
if (key.charAt(0) !== '$') {
let options = apollo[key]
if(apollo.$query) {
options = Object.assign({}, apollo.$query, options)
}
if (!hasProperty(this, key) && !hasProperty(this.$props, key) && !hasProperty(this.$data, key)) {
Object.defineProperty(this, key, {
get: () => this.$data.$apolloData.data[key],
enumerable: true,
configurable: true,
})
}
this.$apollo.addSmartQuery(key, apollo[key])
this.$apollo.addSmartQuery(key, options)
}
}

Expand Down