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.20 to 0.0.21

28

index.js

@@ -6,2 +6,3 @@ 'use strict';

const graphql = require('graphql');
const helper = require('@kitql/helper');

@@ -34,6 +35,9 @@ (function (RequestStatus) {

this.headersContentType = options.headersContentType || 'application/graphql+json';
this.logLevel = options.logLevel || 'all';
this.log = new helper.Log('KitQL Client');
}
async request({ skFetch, document, variables, cacheKey, cacheMs }) {
async request({ skFetch, document, variables, cacheKey, cacheMs, browser }) {
//Cache key... Relys on the order of the variables :s
const key = JSON.stringify({ cacheKey, variables });
const needToLog = this.logLevel === 'all' || (this.logLevel === 'server' && !browser);
// Check the cache

@@ -44,5 +48,27 @@ if (cacheMs !== 0 && this.cache[key] !== undefined) {

if (xMs < (cacheMs || this.cacheMs)) {
if (needToLog) {
this.log.info(`${helper.logCyan('Mode:')} ` +
`${helper.logGreen(browser ? 'browser' : 'ssr')}, ` +
`${helper.logCyan('From:')} ${helper.logGreen('CACHE')}, ` +
`${helper.logCyan('Operation:')} ${helper.logGreen(cacheKey)}`);
}
return { ...this.cache[key], from: exports.RequestFrom.CACHE };
}
}
if (needToLog) {
this.log.info(`${helper.logCyan('Mode:')} ` +
`${helper.logGreen(browser ? 'browser' : 'ssr')}, ` +
`${helper.logCyan('From:')} ${helper.logGreen('NETWORK')}, ` +
`${helper.logCyan('Operation:')} ${helper.logGreen(cacheKey)}`);
}
// If
// 1/ we are in SSR
// 2/ we don't provide a fetch function
// 3/ credentials is 'include'
// => You are probably doing something wrong!
if (!browser && !skFetch && this.credentials === 'include') {
this.log.error(`I think that either:` +
`\n\t\t1/ you forgot to provide \`fetch\`! As we are in SSR & include here. > ${cacheKey}({ fetch: ??? })` +
`\n\t\t2/ you should run this in a browser only.`);
}
const fetchToUse = skFetch ? skFetch : fetch;

@@ -49,0 +75,0 @@ let dateToReturn = {

@@ -18,2 +18,3 @@ export declare type ClientSettings = {

headersContentType?: 'application/graphql+json' | 'application/json';
logLevel: 'all' | 'server' | 'none';
};

@@ -64,5 +65,7 @@ export declare type RequestSettings = {

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

@@ -73,3 +76,4 @@ document: any;

cacheMs: any;
browser: any;
}): Promise<ResponseResult<D, V>>;
}

8

package.json
{
"name": "@kitql/client",
"version": "0.0.20",
"version": "0.0.21",
"dependencies": {
"graphql": "16.2.0"
"@kitql/helper": "0.0.2",
"graphql": "16.3.0"
},

@@ -13,2 +14,5 @@ "repository": {

"license": "MIT",
"engines": {
"node": "17.4.0"
},
"main": "index.js",

@@ -15,0 +19,0 @@ "module": "index.mjs",

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