@graphql-tools/load 7.5.14-alpha-7052f15d.0 → 7.5.14

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/index.js CHANGED
@@ -30,7 +30,6 @@ const pLimit = _interopDefault(require('p-limit'));
30
30
  const module$1 = require('module');
31
31
  const path = require('path');
32
32
  const schema = require('@graphql-tools/schema');
33
- const merge = require('@graphql-tools/merge');
34
33
 
35
34
  function normalizePointers(unnormalizedPointerOrPointers) {
36
35
  const ignore = [];
@@ -609,11 +608,22 @@ function loadDocumentsSync(pointerOrPointers, options) {
609
608
  * @param options Additional options
610
609
  */
611
610
  async function loadSchema(schemaPointers, options) {
611
+ var _a;
612
612
  const sources = await loadTypedefs(schemaPointers, {
613
613
  ...options,
614
614
  filterKinds: OPERATION_KINDS,
615
615
  });
616
- return getSchemaFromSources(sources, options);
616
+ const { schemas, typeDefs } = collectSchemasAndTypeDefs(sources);
617
+ const mergeSchemasOptions = {
618
+ ...options,
619
+ schemas: schemas.concat((_a = options.schemas) !== null && _a !== void 0 ? _a : []),
620
+ typeDefs,
621
+ };
622
+ const schema$1 = schema.mergeSchemas(mergeSchemasOptions);
623
+ if (options === null || options === void 0 ? void 0 : options.includeSources) {
624
+ includeSources(schema$1, sources);
625
+ }
626
+ return options.sort ? graphql.lexicographicSortSchema(schema$1) : schema$1;
617
627
  }
618
628
  /**
619
629
  * Synchronously loads a schema from the provided pointers.
@@ -625,7 +635,16 @@ function loadSchemaSync(schemaPointers, options) {
625
635
  filterKinds: OPERATION_KINDS,
626
636
  ...options,
627
637
  });
628
- return getSchemaFromSources(sources, options);
638
+ const { schemas, typeDefs } = collectSchemasAndTypeDefs(sources);
639
+ const schema$1 = schema.mergeSchemas({
640
+ schemas,
641
+ typeDefs,
642
+ ...options,
643
+ });
644
+ if (options === null || options === void 0 ? void 0 : options.includeSources) {
645
+ includeSources(schema$1, sources);
646
+ }
647
+ return options.sort ? graphql.lexicographicSortSchema(schema$1) : schema$1;
629
648
  }
630
649
  function includeSources(schema, sources) {
631
650
  const finalSources = [];
@@ -643,40 +662,20 @@ function includeSources(schema, sources) {
643
662
  extendedSources: sources,
644
663
  };
645
664
  }
646
- function getSchemaFromSources(sources, options) {
647
- const { typeDefs, resolvers, schemaExtensions } = collectSchemaParts(sources);
648
- const schema$1 = schema.mergeSchemas({
649
- ...options,
650
- typeDefs,
651
- resolvers,
652
- schemaExtensions,
653
- });
654
- if (options === null || options === void 0 ? void 0 : options.includeSources) {
655
- includeSources(schema$1, sources);
656
- }
657
- return options.sort ? graphql.lexicographicSortSchema(schema$1) : schema$1;
658
- }
659
- function collectSchemaParts(sources) {
665
+ function collectSchemasAndTypeDefs(sources) {
666
+ const schemas = [];
660
667
  const typeDefs = [];
661
- const resolvers = [];
662
- const schemaExtensions = [];
663
668
  for (const source of sources) {
664
669
  if (source.schema) {
665
- typeDefs.push(source.schema);
666
- resolvers.push(utils.getResolversFromSchema(source.schema));
667
- schemaExtensions.push(merge.extractExtensionsFromSchema(source.schema));
670
+ schemas.push(source.schema);
668
671
  }
669
- else {
670
- const typeDef = source.document || source.rawSDL;
671
- if (typeDef) {
672
- typeDefs.push(typeDef);
673
- }
672
+ else if (source.document) {
673
+ typeDefs.push(source.document);
674
674
  }
675
675
  }
676
676
  return {
677
+ schemas,
677
678
  typeDefs,
678
- resolvers,
679
- schemaExtensions,
680
679
  };
681
680
  }
682
681
 
package/index.mjs CHANGED
@@ -1,11 +1,10 @@
1
- import { asArray, AggregateError, isDocumentString, parseGraphQLSDL, getDocumentNodeFromSchema, printSchemaWithDirectives, printWithComments, resetComments, compareStrings, getResolversFromSchema } from '@graphql-tools/utils';
1
+ import { asArray, AggregateError, isDocumentString, parseGraphQLSDL, getDocumentNodeFromSchema, printSchemaWithDirectives, printWithComments, resetComments, compareStrings } from '@graphql-tools/utils';
2
2
  import { cwd, env } from 'process';
3
3
  import { isSchema, Kind, lexicographicSortSchema, Source, print } from 'graphql';
4
4
  import pLimit from 'p-limit';
5
5
  import { createRequire } from 'module';
6
6
  import { join } from 'path';
7
7
  import { mergeSchemas } from '@graphql-tools/schema';
8
- import { extractExtensionsFromSchema } from '@graphql-tools/merge';
9
8
 
10
9
  function normalizePointers(unnormalizedPointerOrPointers) {
11
10
  const ignore = [];
@@ -584,11 +583,22 @@ function loadDocumentsSync(pointerOrPointers, options) {
584
583
  * @param options Additional options
585
584
  */
586
585
  async function loadSchema(schemaPointers, options) {
586
+ var _a;
587
587
  const sources = await loadTypedefs(schemaPointers, {
588
588
  ...options,
589
589
  filterKinds: OPERATION_KINDS,
590
590
  });
591
- return getSchemaFromSources(sources, options);
591
+ const { schemas, typeDefs } = collectSchemasAndTypeDefs(sources);
592
+ const mergeSchemasOptions = {
593
+ ...options,
594
+ schemas: schemas.concat((_a = options.schemas) !== null && _a !== void 0 ? _a : []),
595
+ typeDefs,
596
+ };
597
+ const schema = mergeSchemas(mergeSchemasOptions);
598
+ if (options === null || options === void 0 ? void 0 : options.includeSources) {
599
+ includeSources(schema, sources);
600
+ }
601
+ return options.sort ? lexicographicSortSchema(schema) : schema;
592
602
  }
593
603
  /**
594
604
  * Synchronously loads a schema from the provided pointers.
@@ -600,7 +610,16 @@ function loadSchemaSync(schemaPointers, options) {
600
610
  filterKinds: OPERATION_KINDS,
601
611
  ...options,
602
612
  });
603
- return getSchemaFromSources(sources, options);
613
+ const { schemas, typeDefs } = collectSchemasAndTypeDefs(sources);
614
+ const schema = mergeSchemas({
615
+ schemas,
616
+ typeDefs,
617
+ ...options,
618
+ });
619
+ if (options === null || options === void 0 ? void 0 : options.includeSources) {
620
+ includeSources(schema, sources);
621
+ }
622
+ return options.sort ? lexicographicSortSchema(schema) : schema;
604
623
  }
605
624
  function includeSources(schema, sources) {
606
625
  const finalSources = [];
@@ -618,40 +637,20 @@ function includeSources(schema, sources) {
618
637
  extendedSources: sources,
619
638
  };
620
639
  }
621
- function getSchemaFromSources(sources, options) {
622
- const { typeDefs, resolvers, schemaExtensions } = collectSchemaParts(sources);
623
- const schema = mergeSchemas({
624
- ...options,
625
- typeDefs,
626
- resolvers,
627
- schemaExtensions,
628
- });
629
- if (options === null || options === void 0 ? void 0 : options.includeSources) {
630
- includeSources(schema, sources);
631
- }
632
- return options.sort ? lexicographicSortSchema(schema) : schema;
633
- }
634
- function collectSchemaParts(sources) {
640
+ function collectSchemasAndTypeDefs(sources) {
641
+ const schemas = [];
635
642
  const typeDefs = [];
636
- const resolvers = [];
637
- const schemaExtensions = [];
638
643
  for (const source of sources) {
639
644
  if (source.schema) {
640
- typeDefs.push(source.schema);
641
- resolvers.push(getResolversFromSchema(source.schema));
642
- schemaExtensions.push(extractExtensionsFromSchema(source.schema));
645
+ schemas.push(source.schema);
643
646
  }
644
- else {
645
- const typeDef = source.document || source.rawSDL;
646
- if (typeDef) {
647
- typeDefs.push(typeDef);
648
- }
647
+ else if (source.document) {
648
+ typeDefs.push(source.document);
649
649
  }
650
650
  }
651
651
  return {
652
+ schemas,
652
653
  typeDefs,
653
- resolvers,
654
- schemaExtensions,
655
654
  };
656
655
  }
657
656
 
package/package.json CHANGED
@@ -1,17 +1,16 @@
1
1
  {
2
2
  "name": "@graphql-tools/load",
3
- "version": "7.5.14-alpha-7052f15d.0",
3
+ "version": "7.5.14",
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/merge": "8.2.13",
11
- "@graphql-tools/schema": "9.0.0-alpha-7052f15d.0",
12
- "@graphql-tools/utils": "8.6.12",
10
+ "@graphql-tools/schema": "8.3.14",
11
+ "@graphql-tools/utils": "8.6.13",
13
12
  "p-limit": "3.1.0",
14
- "tslib": "~2.4.0"
13
+ "tslib": "^2.4.0"
15
14
  },
16
15
  "repository": {
17
16
  "type": "git",
package/schema.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { LoadTypedefsOptions, UnnormalizedTypeDefPointer } from './load-typedefs';
2
2
  import { GraphQLSchema, BuildSchemaOptions } from 'graphql';
3
- import { IExecutableSchemaDefinition } from '@graphql-tools/schema';
4
- export declare type LoadSchemaOptions = BuildSchemaOptions & LoadTypedefsOptions & Partial<IExecutableSchemaDefinition> & {
3
+ import { MergeSchemasConfig } from '@graphql-tools/schema';
4
+ export declare type LoadSchemaOptions = BuildSchemaOptions & LoadTypedefsOptions & Partial<MergeSchemasConfig> & {
5
5
  /**
6
6
  * Adds a list of Sources in to `extensions.sources`
7
7
  *