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

@graphql-tools/load

Package Overview
Dependencies
Maintainers
3
Versions
1169
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 5.0.1-alpha-da8d482.0 to 5.0.1-alpha-ecad9d5.0

119

index.cjs.js

@@ -7,27 +7,16 @@ 'use strict';

function _interopNamespace(e) {
if (e && e.__esModule) { return e; } else {
var n = {};
if (e) {
Object.keys(e).forEach(function (k) {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () {
return e[k];
}
});
});
}
n['default'] = e;
return n;
}
}
const utils = require('@graphql-tools/utils');
const process$1 = require('process');
const graphql = require('graphql');
const isGlob = _interopDefault(require('is-glob'));
const pLimit = _interopDefault(require('p-limit'));
const schemaMerging = require('@graphql-tools/schema-merging');
const importFrom = _interopDefault(require('import-from'));
const unixify = _interopDefault(require('unixify'));
const globby = require('globby');
const globby__default = _interopDefault(globby);
const merge = require('@graphql-tools/merge');
const lodash = require('lodash');
const path = require('path');
const fsExtra = require('fs-extra');
const resolveFrom = _interopDefault(require('resolve-from'));

@@ -51,20 +40,6 @@ function normalizePointers(unnormalizedPointerOrPointers) {

options.cache = options.cache || {};
options.cwd = options.cwd || process.cwd();
options.cwd = options.cwd || process$1.cwd();
options.sort = 'sort' in options ? options.sort : true;
options.processedFiles = options.processedFiles || new Map();
}
async function prepareOptions(options) {
applyDefaultOptions(options);
options.fs = await utils.resolveBuiltinModule('fs', options.fs);
options.path = await utils.resolveBuiltinModule('path', options.path);
options.os = await utils.resolveBuiltinModule('os', options.os);
return options;
}
async function prepareOptionsSync(options) {
applyDefaultOptions(options);
options.fs = utils.resolveBuiltinModuleSync('fs', options.fs);
options.path = utils.resolveBuiltinModuleSync('path', options.path);
options.os = utils.resolveBuiltinModuleSync('os', options.os);
return options;
}

@@ -150,5 +125,4 @@ async function loadFile(pointer, options) {

async function getCustomLoaderByPath(path, cwd) {
function getCustomLoaderByPath(path, cwd) {
try {
const { default: importFrom } = await new Promise(function (resolve) { resolve(_interopNamespace(require('import-from'))); });
const requiredModule = importFrom(cwd, path);

@@ -167,19 +141,2 @@ if (requiredModule) {

}
function getCustomLoaderByPathSync(path, cwd) {
try {
let importFrom = require('import-from');
importFrom = importFrom.default || importFrom;
const requiredModule = importFrom(cwd, path);
if (requiredModule) {
if (requiredModule.default && typeof requiredModule.default === 'function') {
return requiredModule.default;
}
if (typeof requiredModule === 'function') {
return requiredModule;
}
}
}
catch (e) { }
return null;
}
async function useCustomLoader(loaderPointer, cwd) {

@@ -201,3 +158,3 @@ let loader;

if (typeof loaderPointer === 'string') {
loader = getCustomLoaderByPathSync(loaderPointer, cwd);
loader = getCustomLoaderByPath(loaderPointer, cwd);
}

@@ -244,3 +201,2 @@ else if (typeof loaderPointer === 'function') {

const queue = useQueue({ concurrency: CONCURRENCY_LIMIT });
const unixify = await new Promise(function (resolve) { resolve(_interopNamespace(require('unixify'))); }).then(m => m.default || m);
const { addSource, addGlob, collect } = createHelpers({

@@ -271,7 +227,5 @@ sources,

options,
unixify,
globs,
});
const { default: globby } = await new Promise(function (resolve) { resolve(_interopNamespace(require('globby'))); });
const paths = await globby(globs, createGlobbyOptions(options));
const paths = await globby__default(globs, createGlobbyOptions(options));
collectSourcesFromGlobals({

@@ -295,4 +249,2 @@ filepaths: paths,

const queue = useSyncQueue();
let unixify = require('unixify');
unixify = unixify.default || unixify;
const { addSource, addGlob, collect } = createHelpers({

@@ -323,6 +275,4 @@ sources,

options,
unixify,
globs,
});
const globby = require('globby');
const paths = globby.sync(globs, createGlobbyOptions(options));

@@ -360,3 +310,3 @@ collectSourcesFromGlobalsSync({

}
function includeIgnored({ options, unixify, globs }) {
function includeIgnored({ options, globs }) {
if (options.ignore) {

@@ -750,3 +700,3 @@ const ignoreList = utils.asArray(options.ignore)

await collectDefinitions(['*'], documentSource, options, typeDefinitions, allDefinitions);
return process$1({
return process({
typeDefinitions,

@@ -767,3 +717,3 @@ options,

collectDefinitionsSync(['*'], documentSource, options, typeDefinitions, allDefinitions);
return process$1({
return process({
typeDefinitions,

@@ -774,3 +724,3 @@ options,

}
function process$1({ typeDefinitions, options, allDefinitions, }) {
function process({ typeDefinitions, options, allDefinitions, }) {
// Post processing of the final schema (missing types, unused types, etc.)

@@ -842,17 +792,12 @@ // Query, Mutation and Subscription should be merged

function resolveModuleFilePath(filePath, importFrom, options) {
const { fs, path } = options;
if (fs && path) {
const fullPath = path.resolve(options.cwd, filePath);
const dirName = path.dirname(fullPath);
if (isGraphQLFile(fullPath) && isGraphQLFile(importFrom)) {
try {
return fs.realpathSync(path.join(dirName, importFrom));
const fullPath = path.resolve(options.cwd, filePath);
const dirName = path.dirname(fullPath);
if (isGraphQLFile(fullPath) && isGraphQLFile(importFrom)) {
try {
return fsExtra.realpathSync(path.join(dirName, importFrom));
}
catch (e) {
if (e.code === 'ENOENT') {
return resolveFrom(dirName, importFrom);
}
catch (e) {
if (e.code === 'ENOENT') {
let resolveFrom = require('resolve-from');
resolveFrom = resolveFrom.default || resolveFrom;
return resolveFrom(dirName, importFrom);
}
}
}

@@ -1069,4 +1014,4 @@ }

if (!input.source.rawSDL) {
input.source.rawSDL = schemaMerging.printWithComments(input.source.document);
schemaMerging.resetComments();
input.source.rawSDL = merge.printWithComments(input.source.document);
merge.resetComments();
}

@@ -1103,3 +1048,3 @@ }

const globOptions = {};
await prepareOptions(options);
applyDefaultOptions(options);
const sources = await collectSources({

@@ -1128,3 +1073,3 @@ pointerOptionMap,

const globOptions = {};
prepareOptionsSync(options);
applyDefaultOptions(options);
const sources = collectSourcesSync({

@@ -1187,3 +1132,3 @@ pointerOptionMap,

};
const schema = await schemaMerging.mergeSchemasAsync(mergeSchemasOptions);
const schema = await merge.mergeSchemasAsync(mergeSchemasOptions);
if (options.includeSources) {

@@ -1205,3 +1150,3 @@ includeSources(schema, sources);

};
const schema = schemaMerging.mergeSchemas(mergeSchemasOptions);
const schema = merge.mergeSchemas(mergeSchemasOptions);
if (options.includeSources) {

@@ -1208,0 +1153,0 @@ includeSources(schema, sources);

@@ -1,7 +0,14 @@

import { asArray, resolveBuiltinModule, resolveBuiltinModuleSync, debugLog, printSchemaWithDirectives, isDocumentString, parseGraphQLSDL, compareNodes, fixSchemaAst, compareStrings } from '@graphql-tools/utils';
import { asArray, debugLog, printSchemaWithDirectives, isDocumentString, parseGraphQLSDL, compareNodes, fixSchemaAst, compareStrings } from '@graphql-tools/utils';
import { cwd } from 'process';
import { isSchema, parse, Kind, Source, print } from 'graphql';
import isGlob from 'is-glob';
import pLimit from 'p-limit';
import { printWithComments, resetComments, mergeSchemasAsync, mergeSchemas } from '@graphql-tools/schema-merging';
import importFrom from 'import-from';
import unixify from 'unixify';
import globby, { sync } from 'globby';
import { printWithComments, resetComments, mergeSchemasAsync, mergeSchemas } from '@graphql-tools/merge';
import { uniqBy, keyBy, reverse, includes, flatten, isEqual, groupBy } from 'lodash';
import { resolve, dirname, join } from 'path';
import { realpathSync } from 'fs-extra';
import resolveFrom from 'resolve-from';

@@ -25,20 +32,6 @@ function normalizePointers(unnormalizedPointerOrPointers) {

options.cache = options.cache || {};
options.cwd = options.cwd || process.cwd();
options.cwd = options.cwd || cwd();
options.sort = 'sort' in options ? options.sort : true;
options.processedFiles = options.processedFiles || new Map();
}
async function prepareOptions(options) {
applyDefaultOptions(options);
options.fs = await resolveBuiltinModule('fs', options.fs);
options.path = await resolveBuiltinModule('path', options.path);
options.os = await resolveBuiltinModule('os', options.os);
return options;
}
async function prepareOptionsSync(options) {
applyDefaultOptions(options);
options.fs = resolveBuiltinModuleSync('fs', options.fs);
options.path = resolveBuiltinModuleSync('path', options.path);
options.os = resolveBuiltinModuleSync('os', options.os);
return options;
}

@@ -124,5 +117,4 @@ async function loadFile(pointer, options) {

async function getCustomLoaderByPath(path, cwd) {
function getCustomLoaderByPath(path, cwd) {
try {
const { default: importFrom } = await import('import-from');
const requiredModule = importFrom(cwd, path);

@@ -141,19 +133,2 @@ if (requiredModule) {

}
function getCustomLoaderByPathSync(path, cwd) {
try {
let importFrom = require('import-from');
importFrom = importFrom.default || importFrom;
const requiredModule = importFrom(cwd, path);
if (requiredModule) {
if (requiredModule.default && typeof requiredModule.default === 'function') {
return requiredModule.default;
}
if (typeof requiredModule === 'function') {
return requiredModule;
}
}
}
catch (e) { }
return null;
}
async function useCustomLoader(loaderPointer, cwd) {

@@ -175,3 +150,3 @@ let loader;

if (typeof loaderPointer === 'string') {
loader = getCustomLoaderByPathSync(loaderPointer, cwd);
loader = getCustomLoaderByPath(loaderPointer, cwd);
}

@@ -218,3 +193,2 @@ else if (typeof loaderPointer === 'function') {

const queue = useQueue({ concurrency: CONCURRENCY_LIMIT });
const unixify = await import('unixify').then(m => m.default || m);
const { addSource, addGlob, collect } = createHelpers({

@@ -245,6 +219,4 @@ sources,

options,
unixify,
globs,
});
const { default: globby } = await import('globby');
const paths = await globby(globs, createGlobbyOptions(options));

@@ -269,4 +241,2 @@ collectSourcesFromGlobals({

const queue = useSyncQueue();
let unixify = require('unixify');
unixify = unixify.default || unixify;
const { addSource, addGlob, collect } = createHelpers({

@@ -297,7 +267,5 @@ sources,

options,
unixify,
globs,
});
const globby = require('globby');
const paths = globby.sync(globs, createGlobbyOptions(options));
const paths = sync(globs, createGlobbyOptions(options));
collectSourcesFromGlobalsSync({

@@ -334,3 +302,3 @@ filepaths: paths,

}
function includeIgnored({ options, unixify, globs }) {
function includeIgnored({ options, globs }) {
if (options.ignore) {

@@ -724,3 +692,3 @@ const ignoreList = asArray(options.ignore)

await collectDefinitions(['*'], documentSource, options, typeDefinitions, allDefinitions);
return process$1({
return process({
typeDefinitions,

@@ -741,3 +709,3 @@ options,

collectDefinitionsSync(['*'], documentSource, options, typeDefinitions, allDefinitions);
return process$1({
return process({
typeDefinitions,

@@ -748,3 +716,3 @@ options,

}
function process$1({ typeDefinitions, options, allDefinitions, }) {
function process({ typeDefinitions, options, allDefinitions, }) {
// Post processing of the final schema (missing types, unused types, etc.)

@@ -816,17 +784,12 @@ // Query, Mutation and Subscription should be merged

function resolveModuleFilePath(filePath, importFrom, options) {
const { fs, path } = options;
if (fs && path) {
const fullPath = path.resolve(options.cwd, filePath);
const dirName = path.dirname(fullPath);
if (isGraphQLFile(fullPath) && isGraphQLFile(importFrom)) {
try {
return fs.realpathSync(path.join(dirName, importFrom));
const fullPath = resolve(options.cwd, filePath);
const dirName = dirname(fullPath);
if (isGraphQLFile(fullPath) && isGraphQLFile(importFrom)) {
try {
return realpathSync(join(dirName, importFrom));
}
catch (e) {
if (e.code === 'ENOENT') {
return resolveFrom(dirName, importFrom);
}
catch (e) {
if (e.code === 'ENOENT') {
let resolveFrom = require('resolve-from');
resolveFrom = resolveFrom.default || resolveFrom;
return resolveFrom(dirName, importFrom);
}
}
}

@@ -1076,3 +1039,3 @@ }

const globOptions = {};
await prepareOptions(options);
applyDefaultOptions(options);
const sources = await collectSources({

@@ -1101,3 +1064,3 @@ pointerOptionMap,

const globOptions = {};
prepareOptionsSync(options);
applyDefaultOptions(options);
const sources = collectSourcesSync({

@@ -1104,0 +1067,0 @@ pointerOptionMap,

@@ -16,5 +16,2 @@ import { Source, SingleFileOptions, Loader } from '@graphql-tools/utils';

forceGraphQLImport?: boolean;
fs?: typeof import('fs');
path?: typeof import('path');
os?: typeof import('os');
};

@@ -21,0 +18,0 @@ export declare type UnnormalizedTypeDefPointer = {

import { LoadTypedefsOptions } from './../load-typedefs';
export declare function prepareOptions<T>(options: LoadTypedefsOptions<Partial<T>>): Promise<LoadTypedefsOptions<Partial<T>>>;
export declare function prepareOptionsSync<T>(options: LoadTypedefsOptions<Partial<T>>): Promise<LoadTypedefsOptions<Partial<T>>>;
export declare function applyDefaultOptions<T>(options: LoadTypedefsOptions<Partial<T>>): void;
{
"name": "@graphql-tools/load",
"version": "5.0.1-alpha-da8d482.0",
"version": "5.0.1-alpha-ecad9d5.0",
"description": "A set of utils for faster development of GraphQL tools",
"peerDependencies": {
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0"
"graphql": "^14.0.0 || ^15.0.0"
},
"dependencies": {
"@graphql-tools/utils": "5.0.1-alpha-da8d482.0",
"@graphql-tools/schema-merging": "5.0.1-alpha-da8d482.0",
"aggregate-error": "3.0.1",
"@graphql-tools/utils": "5.0.1-alpha-ecad9d5.0",
"@graphql-tools/merge": "5.0.1-alpha-ecad9d5.0",
"fs-extra": "9.0.0",
"globby": "11.0.0",

@@ -32,2 +32,3 @@ "import-from": "^3.0.0",

"devDependencies": {
"@types/fs-extra": "8.1.0",
"@types/is-glob": "4.0.1",

@@ -34,0 +35,0 @@ "@types/lodash": "4.14.150",

import { LoadTypedefsOptions, UnnormalizedTypeDefPointer } from './load-typedefs';
import { GraphQLSchema, BuildSchemaOptions } from 'graphql';
import { MergeSchemasConfig } from '@graphql-tools/schema-merging';
import { MergeSchemasConfig } from '@graphql-tools/merge';
export declare type LoadSchemaOptions = BuildSchemaOptions & LoadTypedefsOptions & Partial<MergeSchemasConfig> & {

@@ -5,0 +5,0 @@ /**

@@ -1,4 +0,3 @@

export declare function getCustomLoaderByPath(path: string, cwd: string): Promise<any>;
export declare function getCustomLoaderByPathSync(path: string, cwd: string): any;
export declare function getCustomLoaderByPath(path: string, cwd: string): any;
export declare function useCustomLoader(loaderPointer: any, cwd: string): Promise<any>;
export declare function useCustomLoaderSync(loaderPointer: any, cwd: string): any;

Sorry, the diff of this file is not supported yet

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