@graphql-tools/load 8.0.0 → 8.0.1-alpha-20231101094738-8c69848a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/documents.js CHANGED
@@ -22,7 +22,11 @@ exports.NON_OPERATION_KINDS = Object.keys(graphql_1.Kind)
22
22
  * @param options Additional options
23
23
  */
24
24
  function loadDocuments(pointerOrPointers, options) {
25
- return (0, load_typedefs_js_1.loadTypedefs)(pointerOrPointers, { noRequire: true, filterKinds: exports.NON_OPERATION_KINDS, ...options });
25
+ return (0, load_typedefs_js_1.loadTypedefs)(pointerOrPointers, {
26
+ noRequire: true,
27
+ filterKinds: exports.NON_OPERATION_KINDS,
28
+ ...options,
29
+ });
26
30
  }
27
31
  exports.loadDocuments = loadDocuments;
28
32
  /**
@@ -34,6 +38,10 @@ exports.loadDocuments = loadDocuments;
34
38
  * @param options Additional options
35
39
  */
36
40
  function loadDocumentsSync(pointerOrPointers, options) {
37
- return (0, load_typedefs_js_1.loadTypedefsSync)(pointerOrPointers, { noRequire: true, filterKinds: exports.NON_OPERATION_KINDS, ...options });
41
+ return (0, load_typedefs_js_1.loadTypedefsSync)(pointerOrPointers, {
42
+ noRequire: true,
43
+ filterKinds: exports.NON_OPERATION_KINDS,
44
+ ...options,
45
+ });
38
46
  }
39
47
  exports.loadDocumentsSync = loadDocumentsSync;
@@ -1,13 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.filterKind = void 0;
4
- const graphql_1 = require("graphql");
5
4
  const process_1 = require("process");
5
+ const graphql_1 = require("graphql");
6
6
  /**
7
7
  * @internal
8
8
  */
9
9
  const filterKind = (content, filterKinds) => {
10
- if (content && content.definitions && content.definitions.length && filterKinds && filterKinds.length > 0) {
10
+ if (content &&
11
+ content.definitions &&
12
+ content.definitions.length &&
13
+ filterKinds &&
14
+ filterKinds.length > 0) {
11
15
  const invalidDefinitions = [];
12
16
  const validDefinitions = [];
13
17
  for (const definitionNode of content.definitions) {
@@ -24,14 +24,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.collectSourcesSync = exports.collectSources = void 0;
27
- const utils_1 = require("@graphql-tools/utils");
27
+ const module_1 = require("module");
28
+ const process_1 = require("process");
28
29
  const graphql_1 = require("graphql");
29
- const load_file_js_1 = require("./load-file.js");
30
- const helpers_js_1 = require("../utils/helpers.js");
30
+ const utils_1 = require("@graphql-tools/utils");
31
31
  const custom_loader_js_1 = require("../utils/custom-loader.js");
32
+ const helpers_js_1 = require("../utils/helpers.js");
32
33
  const queue_js_1 = require("../utils/queue.js");
33
- const module_1 = require("module");
34
- const process_1 = require("process");
34
+ const load_file_js_1 = require("./load-file.js");
35
35
  const CONCURRENCY_LIMIT = 50;
36
36
  async function collectSources({ pointerOptionMap, options, }) {
37
37
  if (process_1.env['DEBUG'] != null) {
@@ -107,7 +107,7 @@ function collectSourcesSync({ pointerOptionMap, options, }) {
107
107
  return sources;
108
108
  }
109
109
  exports.collectSourcesSync = collectSourcesSync;
110
- function createHelpers({ sources, stack }) {
110
+ function createHelpers({ sources, stack, }) {
111
111
  const addSource = ({ source }) => {
112
112
  sources.push(source);
113
113
  };
@@ -221,7 +221,7 @@ function collectCustomLoaderSync({ pointer, pointerOptions, queue, addSource, op
221
221
  }
222
222
  next();
223
223
  }
224
- function collectFallback({ queue, pointer, options, pointerOptions, addSource }) {
224
+ function collectFallback({ queue, pointer, options, pointerOptions, addSource, }) {
225
225
  return queue(async () => {
226
226
  if (process_1.env['DEBUG'] != null) {
227
227
  console.time(`@graphql-tools/load: collectFallback ${pointer}`);
@@ -240,7 +240,7 @@ function collectFallback({ queue, pointer, options, pointerOptions, addSource })
240
240
  }
241
241
  });
242
242
  }
243
- function collectFallbackSync({ queue, pointer, options, pointerOptions, addSource }) {
243
+ function collectFallbackSync({ queue, pointer, options, pointerOptions, addSource, }) {
244
244
  return queue(() => {
245
245
  if (process_1.env['DEBUG'] != null) {
246
246
  console.time(`@graphql-tools/load: collectFallbackSync ${pointer}`);
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseSource = void 0;
4
- const utils_1 = require("@graphql-tools/utils");
5
4
  const process_1 = require("process");
5
+ const utils_1 = require("@graphql-tools/utils");
6
6
  const filter_document_kind_js_1 = require("../filter-document-kind.js");
7
- function parseSource({ partialSource, options, pointerOptionMap, addValidSource }) {
7
+ function parseSource({ partialSource, options, pointerOptionMap, addValidSource, }) {
8
8
  if (process_1.env['DEBUG'] != null) {
9
9
  console.time(`@graphql-tools/load: parseSource ${partialSource.location}`);
10
10
  }
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadTypedefsSync = exports.loadTypedefs = void 0;
4
+ const process_1 = require("process");
4
5
  const utils_1 = require("@graphql-tools/utils");
5
- const pointers_js_1 = require("./utils/pointers.js");
6
- const options_js_1 = require("./load-typedefs/options.js");
7
6
  const collect_sources_js_1 = require("./load-typedefs/collect-sources.js");
7
+ const options_js_1 = require("./load-typedefs/options.js");
8
8
  const parse_js_1 = require("./load-typedefs/parse.js");
9
9
  const helpers_js_1 = require("./utils/helpers.js");
10
- const process_1 = require("process");
10
+ const pointers_js_1 = require("./utils/pointers.js");
11
11
  const CONCURRENCY_LIMIT = 100;
12
12
  /**
13
13
  * Asynchronously loads any GraphQL documents (i.e. executable documents like
package/cjs/schema.js CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadSchemaSync = exports.loadSchema = void 0;
4
- const load_typedefs_js_1 = require("./load-typedefs.js");
5
4
  const graphql_1 = require("graphql");
6
- const documents_js_1 = require("./documents.js");
7
5
  const schema_1 = require("@graphql-tools/schema");
8
6
  const utils_1 = require("@graphql-tools/utils");
7
+ const documents_js_1 = require("./documents.js");
8
+ const load_typedefs_js_1 = require("./load-typedefs.js");
9
9
  /**
10
10
  * Asynchronously loads a schema from the provided pointers.
11
11
  * @param schemaPointers Pointers to the sources to load the schema from
@@ -49,7 +49,10 @@ function includeSources(schema, sources) {
49
49
  };
50
50
  }
51
51
  function getSchemaFromSources(sources, options) {
52
- if (sources.length === 1 && sources[0].schema != null && options.typeDefs == null && options.resolvers == null) {
52
+ if (sources.length === 1 &&
53
+ sources[0].schema != null &&
54
+ options.typeDefs == null &&
55
+ options.resolvers == null) {
53
56
  return options.sort ? (0, graphql_1.lexicographicSortSchema)(sources[0].schema) : sources[0].schema;
54
57
  }
55
58
  const { typeDefs, resolvers, schemaExtensions } = collectSchemaParts(sources);
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizePointers = void 0;
4
- const utils_1 = require("@graphql-tools/utils");
5
4
  const process_1 = require("process");
5
+ const utils_1 = require("@graphql-tools/utils");
6
6
  function normalizePointers(unnormalizedPointerOrPointers) {
7
7
  if (process_1.env['DEBUG'] != null) {
8
8
  console.time(`@graphql-tools/load: normalizePointers`);
@@ -5,7 +5,9 @@ const tslib_1 = require("tslib");
5
5
  const p_limit_1 = tslib_1.__importDefault(require("p-limit"));
6
6
  function useQueue(options) {
7
7
  const queue = [];
8
- const limit = options?.concurrency ? (0, p_limit_1.default)(options.concurrency) : async (fn) => fn();
8
+ const limit = options?.concurrency
9
+ ? (0, p_limit_1.default)(options.concurrency)
10
+ : async (fn) => fn();
9
11
  return {
10
12
  add(fn) {
11
13
  queue.push(() => limit(fn));
package/esm/documents.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Kind } from 'graphql';
2
- import { loadTypedefs, loadTypedefsSync } from './load-typedefs.js';
2
+ import { loadTypedefs, loadTypedefsSync, } from './load-typedefs.js';
3
3
  /**
4
4
  * Kinds of AST nodes that are included in executable documents
5
5
  */
@@ -19,7 +19,11 @@ export const NON_OPERATION_KINDS = Object.keys(Kind)
19
19
  * @param options Additional options
20
20
  */
21
21
  export function loadDocuments(pointerOrPointers, options) {
22
- return loadTypedefs(pointerOrPointers, { noRequire: true, filterKinds: NON_OPERATION_KINDS, ...options });
22
+ return loadTypedefs(pointerOrPointers, {
23
+ noRequire: true,
24
+ filterKinds: NON_OPERATION_KINDS,
25
+ ...options,
26
+ });
23
27
  }
24
28
  /**
25
29
  * Synchronously loads executable documents (i.e. operations and fragments) from
@@ -30,5 +34,9 @@ export function loadDocuments(pointerOrPointers, options) {
30
34
  * @param options Additional options
31
35
  */
32
36
  export function loadDocumentsSync(pointerOrPointers, options) {
33
- return loadTypedefsSync(pointerOrPointers, { noRequire: true, filterKinds: NON_OPERATION_KINDS, ...options });
37
+ return loadTypedefsSync(pointerOrPointers, {
38
+ noRequire: true,
39
+ filterKinds: NON_OPERATION_KINDS,
40
+ ...options,
41
+ });
34
42
  }
@@ -1,10 +1,14 @@
1
- import { Kind } from 'graphql';
2
1
  import { env } from 'process';
2
+ import { Kind } from 'graphql';
3
3
  /**
4
4
  * @internal
5
5
  */
6
6
  export const filterKind = (content, filterKinds) => {
7
- if (content && content.definitions && content.definitions.length && filterKinds && filterKinds.length > 0) {
7
+ if (content &&
8
+ content.definitions &&
9
+ content.definitions.length &&
10
+ filterKinds &&
11
+ filterKinds.length > 0) {
8
12
  const invalidDefinitions = [];
9
13
  const validDefinitions = [];
10
14
  for (const definitionNode of content.definitions) {
@@ -1,11 +1,11 @@
1
- import { isDocumentString, parseGraphQLSDL, getDocumentNodeFromSchema, asArray } from '@graphql-tools/utils';
1
+ import { createRequire } from 'module';
2
+ import { cwd, env } from 'process';
2
3
  import { isSchema, Kind } from 'graphql';
3
- import { loadFile, loadFileSync } from './load-file.js';
4
- import { stringToHash, useStack } from '../utils/helpers.js';
4
+ import { asArray, getDocumentNodeFromSchema, isDocumentString, parseGraphQLSDL, } from '@graphql-tools/utils';
5
5
  import { useCustomLoader, useCustomLoaderSync } from '../utils/custom-loader.js';
6
+ import { stringToHash, useStack } from '../utils/helpers.js';
6
7
  import { useQueue, useSyncQueue } from '../utils/queue.js';
7
- import { createRequire } from 'module';
8
- import { cwd, env } from 'process';
8
+ import { loadFile, loadFileSync } from './load-file.js';
9
9
  const CONCURRENCY_LIMIT = 50;
10
10
  export async function collectSources({ pointerOptionMap, options, }) {
11
11
  if (env['DEBUG'] != null) {
@@ -79,7 +79,7 @@ export function collectSourcesSync({ pointerOptionMap, options, }) {
79
79
  }
80
80
  return sources;
81
81
  }
82
- function createHelpers({ sources, stack }) {
82
+ function createHelpers({ sources, stack, }) {
83
83
  const addSource = ({ source }) => {
84
84
  sources.push(source);
85
85
  };
@@ -193,7 +193,7 @@ function collectCustomLoaderSync({ pointer, pointerOptions, queue, addSource, op
193
193
  }
194
194
  next();
195
195
  }
196
- function collectFallback({ queue, pointer, options, pointerOptions, addSource }) {
196
+ function collectFallback({ queue, pointer, options, pointerOptions, addSource, }) {
197
197
  return queue(async () => {
198
198
  if (env['DEBUG'] != null) {
199
199
  console.time(`@graphql-tools/load: collectFallback ${pointer}`);
@@ -212,7 +212,7 @@ function collectFallback({ queue, pointer, options, pointerOptions, addSource })
212
212
  }
213
213
  });
214
214
  }
215
- function collectFallbackSync({ queue, pointer, options, pointerOptions, addSource }) {
215
+ function collectFallbackSync({ queue, pointer, options, pointerOptions, addSource, }) {
216
216
  return queue(() => {
217
217
  if (env['DEBUG'] != null) {
218
218
  console.time(`@graphql-tools/load: collectFallbackSync ${pointer}`);
@@ -1,7 +1,7 @@
1
- import { printSchemaWithDirectives, parseGraphQLSDL, printWithComments, resetComments, } from '@graphql-tools/utils';
2
1
  import { env } from 'process';
2
+ import { parseGraphQLSDL, printSchemaWithDirectives, printWithComments, resetComments, } from '@graphql-tools/utils';
3
3
  import { filterKind } from '../filter-document-kind.js';
4
- export function parseSource({ partialSource, options, pointerOptionMap, addValidSource }) {
4
+ export function parseSource({ partialSource, options, pointerOptionMap, addValidSource, }) {
5
5
  if (env['DEBUG'] != null) {
6
6
  console.time(`@graphql-tools/load: parseSource ${partialSource.location}`);
7
7
  }
@@ -1,10 +1,10 @@
1
- import { compareStrings, asArray } from '@graphql-tools/utils';
2
- import { normalizePointers } from './utils/pointers.js';
3
- import { applyDefaultOptions } from './load-typedefs/options.js';
1
+ import { env } from 'process';
2
+ import { asArray, compareStrings } from '@graphql-tools/utils';
4
3
  import { collectSources, collectSourcesSync } from './load-typedefs/collect-sources.js';
4
+ import { applyDefaultOptions } from './load-typedefs/options.js';
5
5
  import { parseSource } from './load-typedefs/parse.js';
6
6
  import { useLimit } from './utils/helpers.js';
7
- import { env } from 'process';
7
+ import { normalizePointers } from './utils/pointers.js';
8
8
  const CONCURRENCY_LIMIT = 100;
9
9
  /**
10
10
  * Asynchronously loads any GraphQL documents (i.e. executable documents like
package/esm/schema.js CHANGED
@@ -1,8 +1,8 @@
1
- import { loadTypedefs, loadTypedefsSync } from './load-typedefs.js';
2
- import { Source as GraphQLSource, print, lexicographicSortSchema } from 'graphql';
1
+ import { Source as GraphQLSource, lexicographicSortSchema, print, } from 'graphql';
2
+ import { extractExtensionsFromSchema, mergeSchemas, } from '@graphql-tools/schema';
3
+ import { getResolversFromSchema, } from '@graphql-tools/utils';
3
4
  import { OPERATION_KINDS } from './documents.js';
4
- import { mergeSchemas, extractExtensionsFromSchema } from '@graphql-tools/schema';
5
- import { getResolversFromSchema } from '@graphql-tools/utils';
5
+ import { loadTypedefs, loadTypedefsSync, } from './load-typedefs.js';
6
6
  /**
7
7
  * Asynchronously loads a schema from the provided pointers.
8
8
  * @param schemaPointers Pointers to the sources to load the schema from
@@ -44,7 +44,10 @@ function includeSources(schema, sources) {
44
44
  };
45
45
  }
46
46
  function getSchemaFromSources(sources, options) {
47
- if (sources.length === 1 && sources[0].schema != null && options.typeDefs == null && options.resolvers == null) {
47
+ if (sources.length === 1 &&
48
+ sources[0].schema != null &&
49
+ options.typeDefs == null &&
50
+ options.resolvers == null) {
48
51
  return options.sort ? lexicographicSortSchema(sources[0].schema) : sources[0].schema;
49
52
  }
50
53
  const { typeDefs, resolvers, schemaExtensions } = collectSchemaParts(sources);
@@ -1,5 +1,5 @@
1
- import { asArray } from '@graphql-tools/utils';
2
1
  import { env } from 'process';
2
+ import { asArray } from '@graphql-tools/utils';
3
3
  export function normalizePointers(unnormalizedPointerOrPointers) {
4
4
  if (env['DEBUG'] != null) {
5
5
  console.time(`@graphql-tools/load: normalizePointers`);
@@ -1,7 +1,9 @@
1
1
  import pLimit from 'p-limit';
2
2
  export function useQueue(options) {
3
3
  const queue = [];
4
- const limit = options?.concurrency ? pLimit(options.concurrency) : async (fn) => fn();
4
+ const limit = options?.concurrency
5
+ ? pLimit(options.concurrency)
6
+ : async (fn) => fn();
5
7
  return {
6
8
  add(fn) {
7
9
  queue.push(() => limit(fn));
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@graphql-tools/load",
3
- "version": "8.0.0",
3
+ "version": "8.0.1-alpha-20231101094738-8c69848a",
4
4
  "description": "A set of utils for faster development of GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
8
8
  },
9
9
  "dependencies": {
10
- "@graphql-tools/utils": "^10.0.0",
11
10
  "@graphql-tools/schema": "^10.0.0",
12
- "p-limit": "3.1.0",
11
+ "@graphql-tools/utils": "^10.0.0",
12
+ "p-limit": "5.0.0",
13
13
  "tslib": "^2.4.0"
14
14
  },
15
15
  "repository": {
@@ -1,5 +1,5 @@
1
- import { Source } from '@graphql-tools/utils';
2
1
  import { Kind } from 'graphql';
2
+ import { Source } from '@graphql-tools/utils';
3
3
  import { LoadTypedefsOptions, UnnormalizedTypeDefPointer } from './load-typedefs.cjs';
4
4
  type KindList = Array<(typeof Kind)[keyof typeof Kind]>;
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { Source } from '@graphql-tools/utils';
2
1
  import { Kind } from 'graphql';
2
+ import { Source } from '@graphql-tools/utils';
3
3
  import { LoadTypedefsOptions, UnnormalizedTypeDefPointer } from './load-typedefs.js';
4
4
  type KindList = Array<(typeof Kind)[keyof typeof Kind]>;
5
5
  /**
@@ -6,5 +6,5 @@ type ParseOptions = {
6
6
  pointerOptionMap: any;
7
7
  addValidSource: AddValidSource;
8
8
  };
9
- export declare function parseSource({ partialSource, options, pointerOptionMap, addValidSource }: ParseOptions): void;
9
+ export declare function parseSource({ partialSource, options, pointerOptionMap, addValidSource, }: ParseOptions): void;
10
10
  export {};
@@ -6,5 +6,5 @@ type ParseOptions = {
6
6
  pointerOptionMap: any;
7
7
  addValidSource: AddValidSource;
8
8
  };
9
- export declare function parseSource({ partialSource, options, pointerOptionMap, addValidSource }: ParseOptions): void;
9
+ export declare function parseSource({ partialSource, options, pointerOptionMap, addValidSource, }: ParseOptions): void;
10
10
  export {};
@@ -1,4 +1,4 @@
1
- import { Source, BaseLoaderOptions, Loader } from '@graphql-tools/utils';
1
+ import { BaseLoaderOptions, Loader, Source } from '@graphql-tools/utils';
2
2
  export type LoadTypedefsOptions<ExtraConfig = {
3
3
  [key: string]: any;
4
4
  }> = BaseLoaderOptions & ExtraConfig & {
@@ -1,4 +1,4 @@
1
- import { Source, BaseLoaderOptions, Loader } from '@graphql-tools/utils';
1
+ import { BaseLoaderOptions, Loader, Source } from '@graphql-tools/utils';
2
2
  export type LoadTypedefsOptions<ExtraConfig = {
3
3
  [key: string]: any;
4
4
  }> = BaseLoaderOptions & ExtraConfig & {
@@ -1,6 +1,6 @@
1
- import { LoadTypedefsOptions, UnnormalizedTypeDefPointer } from './load-typedefs.cjs';
2
- import { GraphQLSchema, BuildSchemaOptions } from 'graphql';
1
+ import { BuildSchemaOptions, GraphQLSchema } from 'graphql';
3
2
  import { IExecutableSchemaDefinition } from '@graphql-tools/schema';
3
+ import { LoadTypedefsOptions, UnnormalizedTypeDefPointer } from './load-typedefs.cjs';
4
4
  export type LoadSchemaOptions = BuildSchemaOptions & LoadTypedefsOptions & Partial<IExecutableSchemaDefinition> & {
5
5
  /**
6
6
  * Adds a list of Sources in to `extensions.sources`
@@ -1,6 +1,6 @@
1
- import { LoadTypedefsOptions, UnnormalizedTypeDefPointer } from './load-typedefs.js';
2
- import { GraphQLSchema, BuildSchemaOptions } from 'graphql';
1
+ import { BuildSchemaOptions, GraphQLSchema } from 'graphql';
3
2
  import { IExecutableSchemaDefinition } from '@graphql-tools/schema';
3
+ import { LoadTypedefsOptions, UnnormalizedTypeDefPointer } from './load-typedefs.js';
4
4
  export type LoadSchemaOptions = BuildSchemaOptions & LoadTypedefsOptions & Partial<IExecutableSchemaDefinition> & {
5
5
  /**
6
6
  * Adds a list of Sources in to `extensions.sources`
@@ -1,4 +1,3 @@
1
- import pLimit from 'p-limit';
2
1
  /**
3
2
  * Converts a string to 32bit integer
4
3
  */
@@ -6,4 +5,4 @@ export declare function stringToHash(str: string): number;
6
5
  export type StackNext = () => void;
7
6
  export type StackFn<T> = (input: T, next: StackNext) => void;
8
7
  export declare function useStack<T>(...fns: Array<StackFn<T>>): (input: T) => void;
9
- export declare function useLimit(concurrency: number): pLimit.Limit;
8
+ export declare function useLimit(concurrency: number): import("p-limit").LimitFunction;
@@ -1,4 +1,3 @@
1
- import pLimit from 'p-limit';
2
1
  /**
3
2
  * Converts a string to 32bit integer
4
3
  */
@@ -6,4 +5,4 @@ export declare function stringToHash(str: string): number;
6
5
  export type StackNext = () => void;
7
6
  export type StackFn<T> = (input: T, next: StackNext) => void;
8
7
  export declare function useStack<T>(...fns: Array<StackFn<T>>): (input: T) => void;
9
- export declare function useLimit(concurrency: number): pLimit.Limit;
8
+ export declare function useLimit(concurrency: number): import("p-limit").LimitFunction;