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
2,514 changes: 183 additions & 2,331 deletions dist/vue-apollo.esm.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

2,514 changes: 183 additions & 2,331 deletions dist/vue-apollo.umd.js

Large diffs are not rendered by default.

6,428 changes: 6,428 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
"apollo-client": "^2.0.0"
},
"dependencies": {
"lodash.debounce": "^4.0.8",
"lodash.omit": "^4.5.0",
"lodash.throttle": "^4.1.1"
"throttle-debounce": "^1.0.1"
},
"devDependencies": {
"@types/graphql": "^0.12.3",
Expand Down
3 changes: 1 addition & 2 deletions src/apollo-provider.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import omit from 'lodash.omit'
import { VUE_APOLLO_QUERY_KEYWORDS } from './consts'
import { getMergedDefinition } from './utils'
import { getMergedDefinition, omit } from './utils'

export class ApolloProvider {
constructor (options) {
Expand Down
7 changes: 3 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import omit from 'lodash.omit'
import { DollarApollo } from './dollar-apollo'
import { ApolloProvider as apolloProvider } from './apollo-provider'
import CApolloQuery from './components/ApolloQuery'
import CApolloSubscribeToMore from './components/ApolloSubscribeToMore'
import CApolloMutation from './components/ApolloMutation'
import { Globals } from './utils'
import { Globals, omit } from './utils'

const keywords = [
'$subscribe',
Expand Down Expand Up @@ -52,8 +51,8 @@ const launch = function launch () {
for (let key in apollo) {
if (key.charAt(0) !== '$') {
let options = apollo[key]
if(apollo.$query) {
options = Object.assign({}, apollo.$query, options)
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, {
Expand Down
3 changes: 1 addition & 2 deletions src/smart-apollo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import omit from 'lodash.omit'
import { throttle, debounce } from './utils'
import { throttle, debounce, omit } from './utils'

export default class SmartApollo {
type = null
Expand Down
22 changes: 11 additions & 11 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import loThrottle from 'lodash.throttle'
import loDebounce from 'lodash.debounce'
import oThrottle from 'throttle-debounce/throttle'
import oDebounce from 'throttle-debounce/debounce'

export const Globals = {}

function factory (action) {
return (cb, options) => {
if (typeof options === 'number') {
return action(cb, options)
} else {
return action(cb, options.wait, options)
}
}
return (cb, time) => action(time. cb)
}

export const throttle = factory(loThrottle)
export const throttle = factory(oThrottle)

export const debounce = factory(loDebounce)
export const debounce = factory(oDebounce)

export function getMergedDefinition (def) {
return Globals.Vue.util.mergeOptions({}, def)
Expand All @@ -27,3 +21,9 @@ export function reapply (options, context) {
}
return options
}

export function omit(obj, properties) {
return Object.entries(obj)
.filter(([key]) => !properties.includes(key))
.reduce((c, [key, val]) => (c[key] = val, c), {})
}