Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kitql/client

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kitql/client - npm Package Compare versions

Comparing version 0.0.28 to 0.0.29

18

index.js

@@ -29,6 +29,6 @@ 'use strict';

constructor(options) {
this.cache = {};
const { url, defaultCache: cacheMs, credentials } = options || {};
this.cacheData = {};
const { url, defaultCache, credentials } = options || {};
this.url = url;
this.cacheMs = cacheMs || 1000 * 60 * 3;
this.cache = defaultCache || 1000 * 60 * 3;
this.credentials = credentials;

@@ -47,3 +47,3 @@ this.headersContentType = options.headersContentType || 'application/graphql+json';

}
async request({ skFetch, document, variables, cacheKey, cacheMs, browser }) {
async request({ skFetch, document, variables, cacheKey, cache, browser }) {
//Cache key... Relys on the order of the variables :s

@@ -59,6 +59,6 @@ const key = JSON.stringify({ cacheKey, variables });

// Check the cache
if (cacheMs !== 0 && this.cache[key] !== undefined) {
const xMs = new Date().getTime() - this.cache[key].date;
if (cache !== 0 && this.cacheData[key] !== undefined) {
const xMs = new Date().getTime() - this.cacheData[key].date;
// cache time of the query or od the default config
if (xMs < (cacheMs || this.cacheMs)) {
if (xMs < (cache || this.cache)) {
if (logOpVar) {

@@ -70,3 +70,3 @@ this.logOperation(browser, exports.RequestFrom.CACHE, cacheKey, JSON.stringify(variables));

}
return { ...this.cache[key], from: exports.RequestFrom.CACHE };
return { ...this.cacheData[key], from: exports.RequestFrom.CACHE };
}

@@ -130,3 +130,3 @@ }

dateToReturn.data = dataJson.data;
this.cache[key] = dateToReturn;
this.cacheData[key] = dateToReturn;
return dateToReturn;

@@ -133,0 +133,0 @@ }

@@ -25,3 +25,3 @@ export declare type ClientSettings = {

/**
* Cache in miliseconds for the Query (so `cacheMs:0` force a network call)
* Cache in miliseconds for the Query (so `cache:0` force a network call)
*/

@@ -66,11 +66,11 @@ cache: number;

private url;
private cacheMs;
private cache;
private credentials;
private headersContentType;
private logType;
private cache;
private cacheData;
private log;
constructor(options: ClientSettings);
private logOperation;
request<D, V>({ skFetch, document, variables, cacheKey, cacheMs, browser }: {
request<D, V>({ skFetch, document, variables, cacheKey, cache, browser }: {
skFetch: any;

@@ -80,5 +80,5 @@ document: any;

cacheKey: any;
cacheMs: any;
cache: any;
browser: any;
}): Promise<ResponseResult<D, V>>;
}
{
"name": "@kitql/client",
"version": "0.0.28",
"version": "0.0.29",
"dependencies": {

@@ -5,0 +5,0 @@ "@kitql/helper": "0.0.4",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc