Socket
Socket
Sign inDemoInstall

@graphql-tools/load

Package Overview
Dependencies
Maintainers
3
Versions
1163
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-tools/load - npm Package Compare versions

Comparing version 8.0.1-alpha-20231101094738-8c69848a to 8.0.1-alpha-20231123133003-7b1f3276

25

cjs/load-typedefs.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadTypedefsSync = exports.loadTypedefs = void 0;
const process_1 = require("process");
const utils_1 = require("@graphql-tools/utils");

@@ -21,5 +20,3 @@ const collect_sources_js_1 = require("./load-typedefs/collect-sources.js");

async function loadTypedefs(pointerOrPointers, options) {
if (process_1.env['DEBUG'] != null) {
console.time('@graphql-tools/load: loadTypedefs');
}
(0, utils_1.debugTimerStart)('@graphql-tools/load: loadTypedefs');
const { ignore, pointerOptionMap } = (0, pointers_js_1.normalizePointers)(pointerOrPointers);

@@ -45,5 +42,3 @@ options.ignore = (0, utils_1.asArray)(options.ignore || []);

const result = prepareResult({ options, pointerOptionMap, validSources });
if (process_1.env['DEBUG'] != null) {
console.timeEnd('@graphql-tools/load: loadTypedefs');
}
(0, utils_1.debugTimerEnd)('@graphql-tools/load: loadTypedefs');
return result;

@@ -60,5 +55,3 @@ }

function loadTypedefsSync(pointerOrPointers, options) {
if (process_1.env['DEBUG'] != null) {
console.time('@graphql-tools/load: loadTypedefsSync');
}
(0, utils_1.debugTimerStart)('@graphql-tools/load: loadTypedefsSync');
const { ignore, pointerOptionMap } = (0, pointers_js_1.normalizePointers)(pointerOrPointers);

@@ -83,5 +76,3 @@ options.ignore = (0, utils_1.asArray)(options.ignore || []).concat(ignore);

const result = prepareResult({ options, pointerOptionMap, validSources });
if (process_1.env['DEBUG'] != null) {
console.timeEnd('@graphql-tools/load: loadTypedefsSync');
}
(0, utils_1.debugTimerEnd)('@graphql-tools/load: loadTypedefsSync');
return result;

@@ -92,5 +83,3 @@ }

function prepareResult({ options, pointerOptionMap, validSources, }) {
if (process_1.env['DEBUG'] != null) {
console.time('@graphql-tools/load: prepareResult');
}
(0, utils_1.debugTimerStart)('@graphql-tools/load: prepareResult');
const pointerList = Object.keys(pointerOptionMap);

@@ -107,6 +96,4 @@ if (pointerList.length > 0 && validSources.length === 0) {

: validSources;
if (process_1.env['DEBUG'] != null) {
console.timeEnd('@graphql-tools/load: prepareResult');
}
(0, utils_1.debugTimerEnd)('@graphql-tools/load: prepareResult');
return sortedResult;
}

@@ -37,5 +37,3 @@ "use strict";

async function collectSources({ pointerOptionMap, options, }) {
if (process_1.env['DEBUG'] != null) {
console.time('@graphql-tools/load: collectSources');
}
(0, utils_1.debugTimerStart)('@graphql-tools/load: collectSources');
const sources = [];

@@ -49,5 +47,3 @@ const queue = (0, queue_js_1.useQueue)({ concurrency: CONCURRENCY_LIMIT });

const pointerOptions = pointerOptionMap[pointer];
if (process_1.env['DEBUG'] != null) {
console.time(`@graphql-tools/load: collectSources ${pointer}`);
}
(0, utils_1.debugTimerStart)(`@graphql-tools/load: collectSources ${pointer}`);
collect({

@@ -61,13 +57,7 @@ pointer,

});
if (process_1.env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: collectSources ${pointer}`);
}
(0, utils_1.debugTimerEnd)(`@graphql-tools/load: collectSources ${pointer}`);
}
if (process_1.env['DEBUG'] != null) {
console.time('@graphql-tools/load: collectSources queue');
}
(0, utils_1.debugTimerStart)('@graphql-tools/load: collectSources queue');
await queue.runAll();
if (process_1.env['DEBUG'] != null) {
console.timeEnd('@graphql-tools/load: collectSources queue');
}
(0, utils_1.debugTimerEnd)('@graphql-tools/load: collectSources queue');
return sources;

@@ -83,10 +73,6 @@ }

});
if (process_1.env['DEBUG'] != null) {
console.time('@graphql-tools/load: collectSourcesSync');
}
(0, utils_1.debugTimerStart)('@graphql-tools/load: collectSourcesSync');
for (const pointer in pointerOptionMap) {
const pointerOptions = pointerOptionMap[pointer];
if (process_1.env['DEBUG'] != null) {
console.time(`@graphql-tools/load: collectSourcesSync ${pointer}`);
}
(0, utils_1.debugTimerStart)(`@graphql-tools/load: collectSourcesSync ${pointer}`);
collect({

@@ -100,13 +86,7 @@ pointer,

});
if (process_1.env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: collectSourcesSync ${pointer}`);
}
(0, utils_1.debugTimerEnd)(`@graphql-tools/load: collectSourcesSync ${pointer}`);
}
if (process_1.env['DEBUG'] != null) {
console.time('@graphql-tools/load: collectSourcesSync queue');
}
(0, utils_1.debugTimerStart)('@graphql-tools/load: collectSourcesSync queue');
queue.runAll();
if (process_1.env['DEBUG'] != null) {
console.timeEnd('@graphql-tools/load: collectSourcesSync queue');
}
(0, utils_1.debugTimerEnd)('@graphql-tools/load: collectSourcesSync queue');
return sources;

@@ -126,5 +106,3 @@ }

function addResultOfCustomLoader({ pointer, result, addSource, }) {
if (process_1.env['DEBUG'] != null) {
console.time(`@graphql-tools/load: addResultOfCustomLoader ${pointer}`);
}
(0, utils_1.debugTimerStart)(`@graphql-tools/load: addResultOfCustomLoader ${pointer}`);
if ((0, graphql_1.isSchema)(result)) {

@@ -159,10 +137,6 @@ addSource({

}
if (process_1.env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: addResultOfCustomLoader ${pointer}`);
}
(0, utils_1.debugTimerEnd)(`@graphql-tools/load: addResultOfCustomLoader ${pointer}`);
}
function collectDocumentString({ pointer, pointerOptions, options, addSource, queue }, next) {
if (process_1.env['DEBUG'] != null) {
console.time(`@graphql-tools/load: collectDocumentString ${pointer}`);
}
(0, utils_1.debugTimerStart)(`@graphql-tools/load: collectDocumentString ${pointer}`);
if ((0, utils_1.isDocumentString)(pointer)) {

@@ -180,5 +154,3 @@ return queue(() => {

}
if (process_1.env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: collectDocumentString ${pointer}`);
}
(0, utils_1.debugTimerEnd)(`@graphql-tools/load: collectDocumentString ${pointer}`);
next();

@@ -189,5 +161,3 @@ }

return queue(async () => {
if (process_1.env['DEBUG'] != null) {
console.time(`@graphql-tools/load: collectCustomLoader ${pointer}`);
}
(0, utils_1.debugTimerStart)(`@graphql-tools/load: collectCustomLoader ${pointer}`);
await Promise.all((0, utils_1.asArray)(pointerOptions.require).map(m => Promise.resolve(`${m}`).then(s => __importStar(require(s)))));

@@ -198,5 +168,3 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment

const result = await loader(pointer, { ...options, ...pointerOptions }, pointerOptionMap);
if (process_1.env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: collectCustomLoader ${pointer}`);
}
(0, utils_1.debugTimerEnd)(`@graphql-tools/load: collectCustomLoader ${pointer}`);
if (!result) {

@@ -213,5 +181,3 @@ return;

return queue(() => {
if (process_1.env['DEBUG'] != null) {
console.time(`@graphql-tools/load: collectCustomLoaderSync ${pointer}`);
}
(0, utils_1.debugTimerStart)(`@graphql-tools/load: collectCustomLoaderSync ${pointer}`);
const cwdRequire = (0, module_1.createRequire)(options.cwd || (0, process_1.cwd)());

@@ -225,5 +191,3 @@ for (const m of (0, utils_1.asArray)(pointerOptions.require)) {

const result = loader(pointer, { ...options, ...pointerOptions }, pointerOptionMap);
if (process_1.env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: collectCustomLoaderSync ${pointer}`);
}
(0, utils_1.debugTimerEnd)(`@graphql-tools/load: collectCustomLoaderSync ${pointer}`);
if (result) {

@@ -238,5 +202,3 @@ addResultOfCustomLoader({ pointer, result, addSource });

return queue(async () => {
if (process_1.env['DEBUG'] != null) {
console.time(`@graphql-tools/load: collectFallback ${pointer}`);
}
(0, utils_1.debugTimerStart)(`@graphql-tools/load: collectFallback ${pointer}`);
const sources = await (0, load_file_js_1.loadFile)(pointer, {

@@ -251,5 +213,3 @@ ...options,

}
if (process_1.env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: collectFallback ${pointer}`);
}
(0, utils_1.debugTimerEnd)(`@graphql-tools/load: collectFallback ${pointer}`);
});

@@ -259,5 +219,3 @@ }

return queue(() => {
if (process_1.env['DEBUG'] != null) {
console.time(`@graphql-tools/load: collectFallbackSync ${pointer}`);
}
(0, utils_1.debugTimerStart)(`@graphql-tools/load: collectFallbackSync ${pointer}`);
const sources = (0, load_file_js_1.loadFileSync)(pointer, {

@@ -272,6 +230,4 @@ ...options,

}
if (process_1.env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: collectFallbackSync ${pointer}`);
}
(0, utils_1.debugTimerEnd)(`@graphql-tools/load: collectFallbackSync ${pointer}`);
});
}

@@ -5,6 +5,5 @@ "use strict";

const process_1 = require("process");
const utils_1 = require("@graphql-tools/utils");
async function loadFile(pointer, options) {
if (process_1.env['DEBUG'] != null) {
console.time(`@graphql-tools/load: loadFile ${pointer}`);
}
(0, utils_1.debugTimerStart)(`@graphql-tools/load: loadFile ${pointer}`);
let results = options.cache?.[pointer];

@@ -45,5 +44,3 @@ if (!results) {

}
if (process_1.env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: loadFile ${pointer}`);
}
(0, utils_1.debugTimerEnd)(`@graphql-tools/load: loadFile ${pointer}`);
return results;

@@ -53,5 +50,3 @@ }

function loadFileSync(pointer, options) {
if (process_1.env['DEBUG'] != null) {
console.time(`@graphql-tools/load: loadFileSync ${pointer}`);
}
(0, utils_1.debugTimerStart)(`@graphql-tools/load: loadFileSync ${pointer}`);
let results = options.cache?.[pointer];

@@ -93,7 +88,5 @@ if (!results) {

}
if (process_1.env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: loadFileSync ${pointer}`);
}
(0, utils_1.debugTimerEnd)(`@graphql-tools/load: loadFileSync ${pointer}`);
return results;
}
exports.loadFileSync = loadFileSync;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseSource = void 0;
const process_1 = require("process");
const utils_1 = require("@graphql-tools/utils");
const filter_document_kind_js_1 = require("../filter-document-kind.js");
function parseSource({ partialSource, options, pointerOptionMap, addValidSource, }) {
if (process_1.env['DEBUG'] != null) {
console.time(`@graphql-tools/load: parseSource ${partialSource.location}`);
}
if (partialSource) {
(0, utils_1.debugTimerStart)(`@graphql-tools/load: parseSource ${partialSource.location}`);
const input = prepareInput({

@@ -24,6 +21,4 @@ source: partialSource,

}
(0, utils_1.debugTimerEnd)(`@graphql-tools/load: parseSource ${partialSource.location}`);
}
if (process_1.env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: parseSource ${partialSource.location}`);
}
}

@@ -45,53 +40,36 @@ exports.parseSource = parseSource;

function parseSchema(input) {
if (process_1.env['DEBUG'] != null) {
console.time(`@graphql-tools/load: parseSchema ${input.source.location}`);
}
if (input.source.schema) {
(0, utils_1.debugTimerStart)(`@graphql-tools/load: parseSchema ${input.source.location}`);
input.source.rawSDL = (0, utils_1.printSchemaWithDirectives)(input.source.schema, input.options);
(0, utils_1.debugTimerEnd)(`@graphql-tools/load: parseSchema ${input.source.location}`);
}
if (process_1.env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: parseSchema ${input.source.location}`);
}
}
function parseRawSDL(input) {
if (process_1.env['DEBUG'] != null) {
console.time(`@graphql-tools/load: parseRawSDL ${input.source.location}`);
}
if (input.source.rawSDL) {
(0, utils_1.debugTimerStart)(`@graphql-tools/load: parseRawSDL ${input.source.location}`);
input.source.document = (0, utils_1.parseGraphQLSDL)(input.source.location, input.source.rawSDL, input.options).document;
(0, utils_1.debugTimerEnd)(`@graphql-tools/load: parseRawSDL ${input.source.location}`);
}
if (process_1.env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: parseRawSDL ${input.source.location}`);
}
}
function useKindsFilter(input) {
if (process_1.env['DEBUG'] != null) {
console.time(`@graphql-tools/load: useKindsFilter ${input.source.location}`);
}
if (input.options.filterKinds) {
(0, utils_1.debugTimerStart)(`@graphql-tools/load: useKindsFilter ${input.source.location}`);
input.source.document = (0, filter_document_kind_js_1.filterKind)(input.source.document, input.options.filterKinds);
(0, utils_1.debugTimerEnd)(`@graphql-tools/load: useKindsFilter ${input.source.location}`);
}
}
function useComments(input) {
if (process_1.env['DEBUG'] != null) {
console.time(`@graphql-tools/load: useComments ${input.source.location}`);
}
if (!input.source.rawSDL && input.source.document) {
(0, utils_1.debugTimerStart)(`@graphql-tools/load: useComments ${input.source.location}`);
input.source.rawSDL = (0, utils_1.printWithComments)(input.source.document);
(0, utils_1.resetComments)();
(0, utils_1.debugTimerEnd)(`@graphql-tools/load: useComments ${input.source.location}`);
}
if (process_1.env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: useComments ${input.source.location}`);
}
}
function collectValidSources(input, addValidSource) {
if (process_1.env['DEBUG'] != null) {
console.time(`@graphql-tools/load: collectValidSources ${input.source.location}`);
}
if (input.source.document?.definitions && input.source.document.definitions.length > 0) {
(0, utils_1.debugTimerStart)(`@graphql-tools/load: collectValidSources ${input.source.location}`);
addValidSource(input.source);
(0, utils_1.debugTimerEnd)(`@graphql-tools/load: collectValidSources ${input.source.location}`);
}
if (process_1.env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: collectValidSources ${input.source.location}`);
}
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizePointers = void 0;
const process_1 = require("process");
const utils_1 = require("@graphql-tools/utils");
function normalizePointers(unnormalizedPointerOrPointers) {
if (process_1.env['DEBUG'] != null) {
console.time(`@graphql-tools/load: normalizePointers`);
}
(0, utils_1.debugTimerStart)('@graphql-tools/load: normalizePointers');
const ignore = [];

@@ -21,5 +18,3 @@ const pointerOptionMap = {};

for (const rawPointer of (0, utils_1.asArray)(unnormalizedPointerOrPointers)) {
if (process_1.env['DEBUG'] != null) {
console.time(`@graphql-tools/load: normalizePointers ${rawPointer}`);
}
(0, utils_1.debugTimerStart)(`@graphql-tools/load: normalizePointers ${rawPointer}`);
if (typeof rawPointer === 'string') {

@@ -36,11 +31,7 @@ handlePointer(rawPointer);

}
if (process_1.env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: normalizePointers ${rawPointer}`);
}
(0, utils_1.debugTimerEnd)(`@graphql-tools/load: normalizePointers ${rawPointer}`);
}
if (process_1.env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: normalizePointers`);
}
(0, utils_1.debugTimerEnd)('@graphql-tools/load: normalizePointers');
return { ignore, pointerOptionMap };
}
exports.normalizePointers = normalizePointers;

@@ -1,3 +0,2 @@

import { env } from 'process';
import { asArray, compareStrings } from '@graphql-tools/utils';
import { asArray, compareStrings, debugTimerEnd, debugTimerStart, } from '@graphql-tools/utils';
import { collectSources, collectSourcesSync } from './load-typedefs/collect-sources.js';

@@ -18,5 +17,3 @@ import { applyDefaultOptions } from './load-typedefs/options.js';

export async function loadTypedefs(pointerOrPointers, options) {
if (env['DEBUG'] != null) {
console.time('@graphql-tools/load: loadTypedefs');
}
debugTimerStart('@graphql-tools/load: loadTypedefs');
const { ignore, pointerOptionMap } = normalizePointers(pointerOrPointers);

@@ -42,5 +39,3 @@ options.ignore = asArray(options.ignore || []);

const result = prepareResult({ options, pointerOptionMap, validSources });
if (env['DEBUG'] != null) {
console.timeEnd('@graphql-tools/load: loadTypedefs');
}
debugTimerEnd('@graphql-tools/load: loadTypedefs');
return result;

@@ -56,5 +51,3 @@ }

export function loadTypedefsSync(pointerOrPointers, options) {
if (env['DEBUG'] != null) {
console.time('@graphql-tools/load: loadTypedefsSync');
}
debugTimerStart('@graphql-tools/load: loadTypedefsSync');
const { ignore, pointerOptionMap } = normalizePointers(pointerOrPointers);

@@ -79,5 +72,3 @@ options.ignore = asArray(options.ignore || []).concat(ignore);

const result = prepareResult({ options, pointerOptionMap, validSources });
if (env['DEBUG'] != null) {
console.timeEnd('@graphql-tools/load: loadTypedefsSync');
}
debugTimerEnd('@graphql-tools/load: loadTypedefsSync');
return result;

@@ -87,5 +78,3 @@ }

function prepareResult({ options, pointerOptionMap, validSources, }) {
if (env['DEBUG'] != null) {
console.time('@graphql-tools/load: prepareResult');
}
debugTimerStart('@graphql-tools/load: prepareResult');
const pointerList = Object.keys(pointerOptionMap);

@@ -102,6 +91,4 @@ if (pointerList.length > 0 && validSources.length === 0) {

: validSources;
if (env['DEBUG'] != null) {
console.timeEnd('@graphql-tools/load: prepareResult');
}
debugTimerEnd('@graphql-tools/load: prepareResult');
return sortedResult;
}
import { createRequire } from 'module';
import { cwd, env } from 'process';
import { cwd } from 'process';
import { isSchema, Kind } from 'graphql';
import { asArray, getDocumentNodeFromSchema, isDocumentString, parseGraphQLSDL, } from '@graphql-tools/utils';
import { asArray, debugTimerEnd, debugTimerStart, getDocumentNodeFromSchema, isDocumentString, parseGraphQLSDL, } from '@graphql-tools/utils';
import { useCustomLoader, useCustomLoaderSync } from '../utils/custom-loader.js';

@@ -11,5 +11,3 @@ import { stringToHash, useStack } from '../utils/helpers.js';

export async function collectSources({ pointerOptionMap, options, }) {
if (env['DEBUG'] != null) {
console.time('@graphql-tools/load: collectSources');
}
debugTimerStart('@graphql-tools/load: collectSources');
const sources = [];

@@ -23,5 +21,3 @@ const queue = useQueue({ concurrency: CONCURRENCY_LIMIT });

const pointerOptions = pointerOptionMap[pointer];
if (env['DEBUG'] != null) {
console.time(`@graphql-tools/load: collectSources ${pointer}`);
}
debugTimerStart(`@graphql-tools/load: collectSources ${pointer}`);
collect({

@@ -35,13 +31,7 @@ pointer,

});
if (env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: collectSources ${pointer}`);
}
debugTimerEnd(`@graphql-tools/load: collectSources ${pointer}`);
}
if (env['DEBUG'] != null) {
console.time('@graphql-tools/load: collectSources queue');
}
debugTimerStart('@graphql-tools/load: collectSources queue');
await queue.runAll();
if (env['DEBUG'] != null) {
console.timeEnd('@graphql-tools/load: collectSources queue');
}
debugTimerEnd('@graphql-tools/load: collectSources queue');
return sources;

@@ -56,10 +46,6 @@ }

});
if (env['DEBUG'] != null) {
console.time('@graphql-tools/load: collectSourcesSync');
}
debugTimerStart('@graphql-tools/load: collectSourcesSync');
for (const pointer in pointerOptionMap) {
const pointerOptions = pointerOptionMap[pointer];
if (env['DEBUG'] != null) {
console.time(`@graphql-tools/load: collectSourcesSync ${pointer}`);
}
debugTimerStart(`@graphql-tools/load: collectSourcesSync ${pointer}`);
collect({

@@ -73,13 +59,7 @@ pointer,

});
if (env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: collectSourcesSync ${pointer}`);
}
debugTimerEnd(`@graphql-tools/load: collectSourcesSync ${pointer}`);
}
if (env['DEBUG'] != null) {
console.time('@graphql-tools/load: collectSourcesSync queue');
}
debugTimerStart('@graphql-tools/load: collectSourcesSync queue');
queue.runAll();
if (env['DEBUG'] != null) {
console.timeEnd('@graphql-tools/load: collectSourcesSync queue');
}
debugTimerEnd('@graphql-tools/load: collectSourcesSync queue');
return sources;

@@ -98,5 +78,3 @@ }

function addResultOfCustomLoader({ pointer, result, addSource, }) {
if (env['DEBUG'] != null) {
console.time(`@graphql-tools/load: addResultOfCustomLoader ${pointer}`);
}
debugTimerStart(`@graphql-tools/load: addResultOfCustomLoader ${pointer}`);
if (isSchema(result)) {

@@ -131,10 +109,6 @@ addSource({

}
if (env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: addResultOfCustomLoader ${pointer}`);
}
debugTimerEnd(`@graphql-tools/load: addResultOfCustomLoader ${pointer}`);
}
function collectDocumentString({ pointer, pointerOptions, options, addSource, queue }, next) {
if (env['DEBUG'] != null) {
console.time(`@graphql-tools/load: collectDocumentString ${pointer}`);
}
debugTimerStart(`@graphql-tools/load: collectDocumentString ${pointer}`);
if (isDocumentString(pointer)) {

@@ -152,5 +126,3 @@ return queue(() => {

}
if (env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: collectDocumentString ${pointer}`);
}
debugTimerEnd(`@graphql-tools/load: collectDocumentString ${pointer}`);
next();

@@ -161,5 +133,3 @@ }

return queue(async () => {
if (env['DEBUG'] != null) {
console.time(`@graphql-tools/load: collectCustomLoader ${pointer}`);
}
debugTimerStart(`@graphql-tools/load: collectCustomLoader ${pointer}`);
await Promise.all(asArray(pointerOptions.require).map(m => import(m)));

@@ -170,5 +140,3 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment

const result = await loader(pointer, { ...options, ...pointerOptions }, pointerOptionMap);
if (env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: collectCustomLoader ${pointer}`);
}
debugTimerEnd(`@graphql-tools/load: collectCustomLoader ${pointer}`);
if (!result) {

@@ -185,5 +153,3 @@ return;

return queue(() => {
if (env['DEBUG'] != null) {
console.time(`@graphql-tools/load: collectCustomLoaderSync ${pointer}`);
}
debugTimerStart(`@graphql-tools/load: collectCustomLoaderSync ${pointer}`);
const cwdRequire = createRequire(options.cwd || cwd());

@@ -197,5 +163,3 @@ for (const m of asArray(pointerOptions.require)) {

const result = loader(pointer, { ...options, ...pointerOptions }, pointerOptionMap);
if (env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: collectCustomLoaderSync ${pointer}`);
}
debugTimerEnd(`@graphql-tools/load: collectCustomLoaderSync ${pointer}`);
if (result) {

@@ -210,5 +174,3 @@ addResultOfCustomLoader({ pointer, result, addSource });

return queue(async () => {
if (env['DEBUG'] != null) {
console.time(`@graphql-tools/load: collectFallback ${pointer}`);
}
debugTimerStart(`@graphql-tools/load: collectFallback ${pointer}`);
const sources = await loadFile(pointer, {

@@ -223,5 +185,3 @@ ...options,

}
if (env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: collectFallback ${pointer}`);
}
debugTimerEnd(`@graphql-tools/load: collectFallback ${pointer}`);
});

@@ -231,5 +191,3 @@ }

return queue(() => {
if (env['DEBUG'] != null) {
console.time(`@graphql-tools/load: collectFallbackSync ${pointer}`);
}
debugTimerStart(`@graphql-tools/load: collectFallbackSync ${pointer}`);
const sources = loadFileSync(pointer, {

@@ -244,6 +202,4 @@ ...options,

}
if (env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: collectFallbackSync ${pointer}`);
}
debugTimerEnd(`@graphql-tools/load: collectFallbackSync ${pointer}`);
});
}
import { env } from 'process';
import { debugTimerEnd, debugTimerStart } from '@graphql-tools/utils';
export async function loadFile(pointer, options) {
if (env['DEBUG'] != null) {
console.time(`@graphql-tools/load: loadFile ${pointer}`);
}
debugTimerStart(`@graphql-tools/load: loadFile ${pointer}`);
let results = options.cache?.[pointer];

@@ -41,11 +40,7 @@ if (!results) {

}
if (env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: loadFile ${pointer}`);
}
debugTimerEnd(`@graphql-tools/load: loadFile ${pointer}`);
return results;
}
export function loadFileSync(pointer, options) {
if (env['DEBUG'] != null) {
console.time(`@graphql-tools/load: loadFileSync ${pointer}`);
}
debugTimerStart(`@graphql-tools/load: loadFileSync ${pointer}`);
let results = options.cache?.[pointer];

@@ -87,6 +82,4 @@ if (!results) {

}
if (env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: loadFileSync ${pointer}`);
}
debugTimerEnd(`@graphql-tools/load: loadFileSync ${pointer}`);
return results;
}

@@ -1,9 +0,6 @@

import { env } from 'process';
import { parseGraphQLSDL, printSchemaWithDirectives, printWithComments, resetComments, } from '@graphql-tools/utils';
import { debugTimerEnd, debugTimerStart, parseGraphQLSDL, printSchemaWithDirectives, printWithComments, resetComments, } from '@graphql-tools/utils';
import { filterKind } from '../filter-document-kind.js';
export function parseSource({ partialSource, options, pointerOptionMap, addValidSource, }) {
if (env['DEBUG'] != null) {
console.time(`@graphql-tools/load: parseSource ${partialSource.location}`);
}
if (partialSource) {
debugTimerStart(`@graphql-tools/load: parseSource ${partialSource.location}`);
const input = prepareInput({

@@ -21,6 +18,4 @@ source: partialSource,

}
debugTimerEnd(`@graphql-tools/load: parseSource ${partialSource.location}`);
}
if (env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: parseSource ${partialSource.location}`);
}
}

@@ -41,53 +36,36 @@ //

function parseSchema(input) {
if (env['DEBUG'] != null) {
console.time(`@graphql-tools/load: parseSchema ${input.source.location}`);
}
if (input.source.schema) {
debugTimerStart(`@graphql-tools/load: parseSchema ${input.source.location}`);
input.source.rawSDL = printSchemaWithDirectives(input.source.schema, input.options);
debugTimerEnd(`@graphql-tools/load: parseSchema ${input.source.location}`);
}
if (env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: parseSchema ${input.source.location}`);
}
}
function parseRawSDL(input) {
if (env['DEBUG'] != null) {
console.time(`@graphql-tools/load: parseRawSDL ${input.source.location}`);
}
if (input.source.rawSDL) {
debugTimerStart(`@graphql-tools/load: parseRawSDL ${input.source.location}`);
input.source.document = parseGraphQLSDL(input.source.location, input.source.rawSDL, input.options).document;
debugTimerEnd(`@graphql-tools/load: parseRawSDL ${input.source.location}`);
}
if (env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: parseRawSDL ${input.source.location}`);
}
}
function useKindsFilter(input) {
if (env['DEBUG'] != null) {
console.time(`@graphql-tools/load: useKindsFilter ${input.source.location}`);
}
if (input.options.filterKinds) {
debugTimerStart(`@graphql-tools/load: useKindsFilter ${input.source.location}`);
input.source.document = filterKind(input.source.document, input.options.filterKinds);
debugTimerEnd(`@graphql-tools/load: useKindsFilter ${input.source.location}`);
}
}
function useComments(input) {
if (env['DEBUG'] != null) {
console.time(`@graphql-tools/load: useComments ${input.source.location}`);
}
if (!input.source.rawSDL && input.source.document) {
debugTimerStart(`@graphql-tools/load: useComments ${input.source.location}`);
input.source.rawSDL = printWithComments(input.source.document);
resetComments();
debugTimerEnd(`@graphql-tools/load: useComments ${input.source.location}`);
}
if (env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: useComments ${input.source.location}`);
}
}
function collectValidSources(input, addValidSource) {
if (env['DEBUG'] != null) {
console.time(`@graphql-tools/load: collectValidSources ${input.source.location}`);
}
if (input.source.document?.definitions && input.source.document.definitions.length > 0) {
debugTimerStart(`@graphql-tools/load: collectValidSources ${input.source.location}`);
addValidSource(input.source);
debugTimerEnd(`@graphql-tools/load: collectValidSources ${input.source.location}`);
}
if (env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: collectValidSources ${input.source.location}`);
}
}

@@ -1,7 +0,4 @@

import { env } from 'process';
import { asArray } from '@graphql-tools/utils';
import { asArray, debugTimerEnd, debugTimerStart } from '@graphql-tools/utils';
export function normalizePointers(unnormalizedPointerOrPointers) {
if (env['DEBUG'] != null) {
console.time(`@graphql-tools/load: normalizePointers`);
}
debugTimerStart('@graphql-tools/load: normalizePointers');
const ignore = [];

@@ -18,5 +15,3 @@ const pointerOptionMap = {};

for (const rawPointer of asArray(unnormalizedPointerOrPointers)) {
if (env['DEBUG'] != null) {
console.time(`@graphql-tools/load: normalizePointers ${rawPointer}`);
}
debugTimerStart(`@graphql-tools/load: normalizePointers ${rawPointer}`);
if (typeof rawPointer === 'string') {

@@ -33,10 +28,6 @@ handlePointer(rawPointer);

}
if (env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: normalizePointers ${rawPointer}`);
}
debugTimerEnd(`@graphql-tools/load: normalizePointers ${rawPointer}`);
}
if (env['DEBUG'] != null) {
console.timeEnd(`@graphql-tools/load: normalizePointers`);
}
debugTimerEnd('@graphql-tools/load: normalizePointers');
return { ignore, pointerOptionMap };
}
{
"name": "@graphql-tools/load",
"version": "8.0.1-alpha-20231101094738-8c69848a",
"version": "8.0.1-alpha-20231123133003-7b1f3276",
"description": "A set of utils for faster development of GraphQL tools",

@@ -10,5 +10,5 @@ "sideEffects": false,

"dependencies": {
"@graphql-tools/schema": "^10.0.0",
"@graphql-tools/utils": "^10.0.0",
"p-limit": "5.0.0",
"@graphql-tools/schema": "10.0.2-alpha-20231123133003-7b1f3276",
"@graphql-tools/utils": "10.0.10-alpha-20231123133003-7b1f3276",
"p-limit": "3.1.0",
"tslib": "^2.4.0"

@@ -15,0 +15,0 @@ },

@@ -0,1 +1,2 @@

import pLimit from 'p-limit';
/**

@@ -8,2 +9,2 @@ * Converts a string to 32bit integer

export declare function useStack<T>(...fns: Array<StackFn<T>>): (input: T) => void;
export declare function useLimit(concurrency: number): import("p-limit").LimitFunction;
export declare function useLimit(concurrency: number): pLimit.Limit;

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