Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

@envelop/graphql-jit

Package Overview
Dependencies
Maintainers
1
Versions
2181
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@envelop/graphql-jit - npm Package Compare versions

Comparing version
1.1.1
to
1.2.0-alpha-15b486f.0
+3
-3
index.d.ts
import { Plugin } from '@envelop/types';
import { ExecutionArgs } from 'graphql';
import { compileQuery, CompilerOptions } from 'graphql-jit';
import { ExecutionArgs, ExecutionResult } from 'graphql';
import { CompilerOptions } from 'graphql-jit';
export declare const useGraphQlJit: (compilerOptions?: Partial<CompilerOptions>, pluginOptions?: {

@@ -12,3 +12,3 @@ /**

*/
onError?: ((r: ReturnType<typeof compileQuery>) => void) | undefined;
onError?: ((r: ExecutionResult) => void) | undefined;
/**

@@ -15,0 +15,0 @@ * Maximum size of LRU Cache

@@ -30,3 +30,3 @@ 'use strict';

setExecuteFn(function jitExecutor() {
var _a;
var _a, _b;
let compiledQuery;

@@ -53,3 +53,3 @@ const documentSource = documentSourceMap.get(args.document);

else {
console.error(compiledQuery);
console.error(((_b = compiledQuery.errors) === null || _b === void 0 ? void 0 : _b.map(e => e.originalError || e)) || compiledQuery);
}

@@ -70,2 +70,1 @@ return {

exports.useGraphQlJit = useGraphQlJit;
//# sourceMappingURL=index.js.map

@@ -24,3 +24,3 @@ import { Source, GraphQLError } from 'graphql';

setExecuteFn(function jitExecutor() {
var _a;
var _a, _b;
let compiledQuery;

@@ -47,3 +47,3 @@ const documentSource = documentSourceMap.get(args.document);

else {
console.error(compiledQuery);
console.error(((_b = compiledQuery.errors) === null || _b === void 0 ? void 0 : _b.map(e => e.originalError || e)) || compiledQuery);
}

@@ -64,2 +64,1 @@ return {

export { useGraphQlJit };
//# sourceMappingURL=index.mjs.map
{
"name": "@envelop/graphql-jit",
"version": "1.1.1",
"version": "1.2.0-alpha-15b486f.0",
"sideEffects": false,
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
},
"dependencies": {
"graphql-jit": "^0.5.0",
"graphql-jit": "^0.6.0",
"tiny-lru": "7.0.6"

@@ -11,0 +11,0 @@ },

{"version":3,"file":"index.js","sources":["../../../dist/plugins/graphql-jit/src/index.js"],"sourcesContent":["import { GraphQLError, Source } from 'graphql';\nimport { compileQuery, isCompiledQuery } from 'graphql-jit';\nimport lru from 'tiny-lru';\nconst DEFAULT_MAX = 1000;\nconst DEFAULT_TTL = 3600000;\nexport const useGraphQlJit = (compilerOptions = {}, pluginOptions = {}) => {\n const max = typeof pluginOptions.max === 'number' ? pluginOptions.max : DEFAULT_MAX;\n const ttl = typeof pluginOptions.ttl === 'number' ? pluginOptions.ttl : DEFAULT_TTL;\n const documentSourceMap = new WeakMap();\n const jitCache = lru(max, ttl);\n return {\n onParse({ params: { source } }) {\n const key = source instanceof Source ? source.body : source;\n return ({ result }) => {\n if (!result || result instanceof Error)\n return;\n documentSourceMap.set(result, key);\n };\n },\n async onExecute({ args, setExecuteFn }) {\n if (!pluginOptions.enableIf || (pluginOptions.enableIf && (await pluginOptions.enableIf(args)))) {\n setExecuteFn(function jitExecutor() {\n var _a;\n let compiledQuery;\n const documentSource = documentSourceMap.get(args.document);\n if (documentSource)\n compiledQuery = jitCache.get(documentSource);\n if (!compiledQuery) {\n compiledQuery = compileQuery(args.schema, args.document, (_a = args.operationName) !== null && _a !== void 0 ? _a : undefined, compilerOptions);\n if (documentSource)\n jitCache.set(documentSource, compiledQuery);\n }\n if (!isCompiledQuery(compiledQuery)) {\n if (pluginOptions === null || pluginOptions === void 0 ? void 0 : pluginOptions.onError) {\n try {\n pluginOptions.onError(compiledQuery);\n }\n catch (e) {\n return {\n errors: [e],\n };\n }\n }\n else {\n console.error(compiledQuery);\n }\n return {\n errors: [new GraphQLError('Error compiling query')],\n };\n }\n else {\n return compiledQuery.query(args.rootValue, args.contextValue, args.variableValues);\n }\n });\n }\n },\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E,yBAAyB,CAAC;AAC1B,qBAAqB;AACrB,yBAAyB;AACzB,wBAAwB,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;AAC3G,qBAAqB;AACrB,iBAAiB,CAAC,CAAC;AACnB,aAAa;AACb,SAAS;AACT,KAAK,CAAC;AACN;;;;"}
{"version":3,"file":"index.mjs","sources":["../../../dist/plugins/graphql-jit/src/index.js"],"sourcesContent":["import { GraphQLError, Source } from 'graphql';\nimport { compileQuery, isCompiledQuery } from 'graphql-jit';\nimport lru from 'tiny-lru';\nconst DEFAULT_MAX = 1000;\nconst DEFAULT_TTL = 3600000;\nexport const useGraphQlJit = (compilerOptions = {}, pluginOptions = {}) => {\n const max = typeof pluginOptions.max === 'number' ? pluginOptions.max : DEFAULT_MAX;\n const ttl = typeof pluginOptions.ttl === 'number' ? pluginOptions.ttl : DEFAULT_TTL;\n const documentSourceMap = new WeakMap();\n const jitCache = lru(max, ttl);\n return {\n onParse({ params: { source } }) {\n const key = source instanceof Source ? source.body : source;\n return ({ result }) => {\n if (!result || result instanceof Error)\n return;\n documentSourceMap.set(result, key);\n };\n },\n async onExecute({ args, setExecuteFn }) {\n if (!pluginOptions.enableIf || (pluginOptions.enableIf && (await pluginOptions.enableIf(args)))) {\n setExecuteFn(function jitExecutor() {\n var _a;\n let compiledQuery;\n const documentSource = documentSourceMap.get(args.document);\n if (documentSource)\n compiledQuery = jitCache.get(documentSource);\n if (!compiledQuery) {\n compiledQuery = compileQuery(args.schema, args.document, (_a = args.operationName) !== null && _a !== void 0 ? _a : undefined, compilerOptions);\n if (documentSource)\n jitCache.set(documentSource, compiledQuery);\n }\n if (!isCompiledQuery(compiledQuery)) {\n if (pluginOptions === null || pluginOptions === void 0 ? void 0 : pluginOptions.onError) {\n try {\n pluginOptions.onError(compiledQuery);\n }\n catch (e) {\n return {\n errors: [e],\n };\n }\n }\n else {\n console.error(compiledQuery);\n }\n return {\n errors: [new GraphQLError('Error compiling query')],\n };\n }\n else {\n return compiledQuery.query(args.rootValue, args.contextValue, args.variableValues);\n }\n });\n }\n },\n };\n};\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;AAGA,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,MAAM,WAAW,GAAG,OAAO,CAAC;AAChB,MAAC,aAAa,GAAG,CAAC,eAAe,GAAG,EAAE,EAAE,aAAa,GAAG,EAAE,KAAK;AAC3E,IAAI,MAAM,GAAG,GAAG,OAAO,aAAa,CAAC,GAAG,KAAK,QAAQ,GAAG,aAAa,CAAC,GAAG,GAAG,WAAW,CAAC;AACxF,IAAI,MAAM,GAAG,GAAG,OAAO,aAAa,CAAC,GAAG,KAAK,QAAQ,GAAG,aAAa,CAAC,GAAG,GAAG,WAAW,CAAC;AACxF,IAAI,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAE,CAAC;AAC5C,IAAI,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACnC,IAAI,OAAO;AACX,QAAQ,OAAO,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;AACxC,YAAY,MAAM,GAAG,GAAG,MAAM,YAAY,MAAM,GAAG,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC;AACxE,YAAY,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK;AACnC,gBAAgB,IAAI,CAAC,MAAM,IAAI,MAAM,YAAY,KAAK;AACtD,oBAAoB,OAAO;AAC3B,gBAAgB,iBAAiB,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACnD,aAAa,CAAC;AACd,SAAS;AACT,QAAQ,MAAM,SAAS,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE;AAChD,YAAY,IAAI,CAAC,aAAa,CAAC,QAAQ,KAAK,aAAa,CAAC,QAAQ,KAAK,MAAM,aAAa,CAAC,QAAQ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