@itinari/vue-saturn
Advanced tools
Comparing version 2.0.0-1 to 2.0.0-2
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.mixin = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -7,2 +8,5 @@ var SmartQuery_1 = require("./SmartQuery"); | ||
data: function () { | ||
if (this.$root.$options.apolloClient === undefined) { | ||
throw new Error('ApolloClient not defined on root component.'); | ||
} | ||
return { | ||
@@ -58,2 +62,3 @@ $apollo: { | ||
smartQuery.stop(); | ||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete | ||
delete _this.$apollo.queries[key]; | ||
@@ -65,8 +70,9 @@ }); | ||
var promises; | ||
var _this = this; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
promises = Object.values(this.$apollo.queries).map(function (smartQuery) { | ||
return smartQuery.prefetch(); | ||
}); | ||
promises = Object.values(this.$apollo.queries).map(function (smartQuery) { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, smartQuery.prefetch()]; | ||
}); }); }); | ||
return [4 /*yield*/, Promise.all(promises)]; | ||
@@ -73,0 +79,0 @@ case 1: |
@@ -25,4 +25,4 @@ import Vue from 'vue'; | ||
export declare class SmartQuery<TCacheShape> { | ||
private options; | ||
private client; | ||
private readonly options; | ||
private readonly client; | ||
private observableQuery; | ||
@@ -32,7 +32,7 @@ private subscription; | ||
constructor(options: SmartQueryOptions); | ||
private readonly skip; | ||
private readonly variables; | ||
private readonly query; | ||
private readonly shouldWatchProps; | ||
private readonly queryOptions; | ||
private get skip(); | ||
private get variables(); | ||
private get query(); | ||
private get shouldWatchProps(); | ||
private get queryOptions(); | ||
private init; | ||
@@ -39,0 +39,0 @@ start(): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SmartQuery = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -11,2 +12,5 @@ var utils_1 = require("./utils"); | ||
this.unwatchProps = null; | ||
if (options.vm.$root.$options.apolloClient === undefined) { | ||
throw new Error('ApolloClient not defined on root component.'); | ||
} | ||
this.options = options; | ||
@@ -21,8 +25,9 @@ this.client = options.vm.$root.$options.apolloClient; | ||
get: function () { | ||
var _a; | ||
if (typeof this.options.skip === 'function') { | ||
return this.options.skip.call(this.options.vm); | ||
} | ||
return this.options.skip || false; | ||
return (_a = this.options.skip) !== null && _a !== void 0 ? _a : false; | ||
}, | ||
enumerable: true, | ||
enumerable: false, | ||
configurable: true | ||
@@ -37,3 +42,3 @@ }); | ||
}, | ||
enumerable: true, | ||
enumerable: false, | ||
configurable: true | ||
@@ -48,3 +53,3 @@ }); | ||
}, | ||
enumerable: true, | ||
enumerable: false, | ||
configurable: true | ||
@@ -58,3 +63,3 @@ }); | ||
}, | ||
enumerable: true, | ||
enumerable: false, | ||
configurable: true | ||
@@ -76,3 +81,3 @@ }); | ||
}, | ||
enumerable: true, | ||
enumerable: false, | ||
configurable: true | ||
@@ -109,5 +114,8 @@ }); | ||
var newOptions = tslib_1.__assign(tslib_1.__assign({}, _this.observableQuery.options), { variables: variables, query: query }); | ||
_this.observableQuery.setOptions(newOptions); | ||
void _this.observableQuery.setOptions(newOptions); | ||
var result = _this.observableQuery.currentResult(); | ||
_this.setLoading(result.loading); | ||
if (result.loading === false && result.networkStatus === 7) { | ||
_this.setValue(result.data); | ||
} | ||
}, 10); | ||
@@ -180,4 +188,3 @@ this.unwatchProps = this.options.vm.$watch(function () { | ||
} | ||
return [4 /*yield*/, this.client.query(this | ||
.queryOptions)]; | ||
return [4 /*yield*/, this.client.query(this.queryOptions)]; | ||
case 1: | ||
@@ -184,0 +191,0 @@ result = _a.sent(); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.debounce = void 0; | ||
function debounce(fn, wait) { | ||
@@ -4,0 +5,0 @@ var timer = null; |
import { SmartQuery } from './SmartQuery'; | ||
export const mixin = { | ||
data() { | ||
if (this.$root.$options.apolloClient === undefined) { | ||
throw new Error('ApolloClient not defined on root component.'); | ||
} | ||
return { | ||
@@ -49,2 +52,3 @@ $apollo: { | ||
smartQuery.stop(); | ||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete | ||
delete this.$apollo.queries[key]; | ||
@@ -54,3 +58,3 @@ }); | ||
async serverPrefetch() { | ||
const promises = Object.values(this.$apollo.queries).map((smartQuery) => smartQuery.prefetch()); | ||
const promises = Object.values(this.$apollo.queries).map(async (smartQuery) => smartQuery.prefetch()); | ||
await Promise.all(promises); | ||
@@ -57,0 +61,0 @@ }, |
@@ -8,2 +8,5 @@ import { debounce } from './utils'; | ||
this.unwatchProps = null; | ||
if (options.vm.$root.$options.apolloClient === undefined) { | ||
throw new Error('ApolloClient not defined on root component.'); | ||
} | ||
this.options = options; | ||
@@ -17,6 +20,7 @@ this.client = options.vm.$root.$options.apolloClient; | ||
get skip() { | ||
var _a; | ||
if (typeof this.options.skip === 'function') { | ||
return this.options.skip.call(this.options.vm); | ||
} | ||
return this.options.skip || false; | ||
return (_a = this.options.skip) !== null && _a !== void 0 ? _a : false; | ||
} | ||
@@ -79,5 +83,8 @@ get variables() { | ||
const newOptions = Object.assign(Object.assign({}, this.observableQuery.options), { variables, query }); | ||
this.observableQuery.setOptions(newOptions); | ||
void this.observableQuery.setOptions(newOptions); | ||
const result = this.observableQuery.currentResult(); | ||
this.setLoading(result.loading); | ||
if (result.loading === false && result.networkStatus === 7) { | ||
this.setValue(result.data); | ||
} | ||
}, 10); | ||
@@ -137,4 +144,3 @@ this.unwatchProps = this.options.vm.$watch(() => { | ||
} | ||
const result = await this.client.query(this | ||
.queryOptions); | ||
const result = await this.client.query(this.queryOptions); | ||
this.setValue(result.data); | ||
@@ -141,0 +147,0 @@ this.setLoading(result.loading); |
@@ -25,4 +25,4 @@ import Vue from 'vue'; | ||
export declare class SmartQuery<TCacheShape> { | ||
private options; | ||
private client; | ||
private readonly options; | ||
private readonly client; | ||
private observableQuery; | ||
@@ -32,7 +32,7 @@ private subscription; | ||
constructor(options: SmartQueryOptions); | ||
private readonly skip; | ||
private readonly variables; | ||
private readonly query; | ||
private readonly shouldWatchProps; | ||
private readonly queryOptions; | ||
private get skip(); | ||
private get variables(); | ||
private get query(); | ||
private get shouldWatchProps(); | ||
private get queryOptions(); | ||
private init; | ||
@@ -39,0 +39,0 @@ start(): void; |
{ | ||
"name": "@itinari/vue-saturn", | ||
"version": "2.0.0-1", | ||
"version": "2.0.0-2", | ||
"description": "VueJS Apollo/GraphQL integration", | ||
@@ -39,15 +39,14 @@ "main": "dist/cjs/index.js", | ||
"devDependencies": { | ||
"@types/node": "^10.14.18", | ||
"@typescript-eslint/eslint-plugin": "^1.13.0", | ||
"@typescript-eslint/parser": "^1.13.0", | ||
"acorn": "^7.1.0", | ||
"apollo-client": "^2.6.4", | ||
"eslint": "^5.16.0", | ||
"@types/node": "^10.17.26", | ||
"@typescript-eslint/eslint-plugin": "^3.3.0", | ||
"@typescript-eslint/parser": "^3.3.0", | ||
"apollo-client": "^2.6.10", | ||
"eslint": "^7.2.0", | ||
"eslint-config-google": "^0.14.0", | ||
"graphql": "^14.5.7", | ||
"tslib": "^1.10.0", | ||
"typescript": "^3.6.3", | ||
"vue": "^2.6.10", | ||
"vue-router": "^3.1.3" | ||
"graphql": "^15.1.0", | ||
"tslib": "^2.0.0", | ||
"typescript": "^3.9.5", | ||
"vue": "^2.6.11", | ||
"vue-router": "^3.3.4" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
60296
11
28
672