@graphql-tools/load 7.5.13 → 7.5.14-alpha-950a29c9.0

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,6 +30,7 @@ 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');
33
34
 
34
35
  function normalizePointers(unnormalizedPointerOrPointers) {
35
36
  const ignore = [];
@@ -608,18 +609,17 @@ function loadDocumentsSync(pointerOrPointers, options) {
608
609
  * @param options Additional options
609
610
  */
610
611
  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
- const { schemas, typeDefs } = collectSchemasAndTypeDefs(sources);
617
- const mergeSchemasOptions = {
616
+ const { typeDefs, resolvers, schemaExtensions } = collectSchemaParts(sources);
617
+ const schema$1 = schema.makeExecutableSchema({
618
618
  ...options,
619
- schemas: schemas.concat((_a = options.schemas) !== null && _a !== void 0 ? _a : []),
620
619
  typeDefs,
621
- };
622
- const schema$1 = schema.mergeSchemas(mergeSchemasOptions);
620
+ resolvers,
621
+ schemaExtensions,
622
+ });
623
623
  if (options === null || options === void 0 ? void 0 : options.includeSources) {
624
624
  includeSources(schema$1, sources);
625
625
  }
@@ -635,11 +635,12 @@ function loadSchemaSync(schemaPointers, options) {
635
635
  filterKinds: OPERATION_KINDS,
636
636
  ...options,
637
637
  });
638
- const { schemas, typeDefs } = collectSchemasAndTypeDefs(sources);
639
- const schema$1 = schema.mergeSchemas({
640
- schemas,
641
- typeDefs,
638
+ const { typeDefs, resolvers, schemaExtensions } = collectSchemaParts(sources);
639
+ const schema$1 = schema.makeExecutableSchema({
642
640
  ...options,
641
+ typeDefs,
642
+ resolvers,
643
+ schemaExtensions,
643
644
  });
644
645
  if (options === null || options === void 0 ? void 0 : options.includeSources) {
645
646
  includeSources(schema$1, sources);
@@ -662,20 +663,27 @@ function includeSources(schema, sources) {
662
663
  extendedSources: sources,
663
664
  };
664
665
  }
665
- function collectSchemasAndTypeDefs(sources) {
666
- const schemas = [];
666
+ function collectSchemaParts(sources) {
667
667
  const typeDefs = [];
668
+ const resolvers = [];
669
+ const schemaExtensions = [];
668
670
  for (const source of sources) {
669
671
  if (source.schema) {
670
- schemas.push(source.schema);
672
+ typeDefs.push(source.schema);
673
+ resolvers.push(utils.getResolversFromSchema(source.schema));
674
+ schemaExtensions.push(merge.extractExtensionsFromSchema(source.schema));
671
675
  }
672
- else if (source.document) {
673
- typeDefs.push(source.document);
676
+ else {
677
+ const typeDef = source.document || source.rawSDL;
678
+ if (typeDef) {
679
+ typeDefs.push(typeDef);
680
+ }
674
681
  }
675
682
  }
676
683
  return {
677
- schemas,
678
684
  typeDefs,
685
+ resolvers,
686
+ schemaExtensions,
679
687
  };
680
688
  }
681
689
 
package/index.mjs CHANGED
@@ -1,10 +1,11 @@
1
- import { asArray, AggregateError, isDocumentString, parseGraphQLSDL, getDocumentNodeFromSchema, printSchemaWithDirectives, printWithComments, resetComments, compareStrings } from '@graphql-tools/utils';
1
+ import { asArray, AggregateError, isDocumentString, parseGraphQLSDL, getDocumentNodeFromSchema, printSchemaWithDirectives, printWithComments, resetComments, compareStrings, getResolversFromSchema } 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
- import { mergeSchemas } from '@graphql-tools/schema';
7
+ import { makeExecutableSchema } from '@graphql-tools/schema';
8
+ import { extractExtensionsFromSchema } from '@graphql-tools/merge';
8
9
 
9
10
  function normalizePointers(unnormalizedPointerOrPointers) {
10
11
  const ignore = [];
@@ -583,18 +584,17 @@ function loadDocumentsSync(pointerOrPointers, options) {
583
584
  * @param options Additional options
584
585
  */
585
586
  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
- const { schemas, typeDefs } = collectSchemasAndTypeDefs(sources);
592
- const mergeSchemasOptions = {
591
+ const { typeDefs, resolvers, schemaExtensions } = collectSchemaParts(sources);
592
+ const schema = makeExecutableSchema({
593
593
  ...options,
594
- schemas: schemas.concat((_a = options.schemas) !== null && _a !== void 0 ? _a : []),
595
594
  typeDefs,
596
- };
597
- const schema = mergeSchemas(mergeSchemasOptions);
595
+ resolvers,
596
+ schemaExtensions,
597
+ });
598
598
  if (options === null || options === void 0 ? void 0 : options.includeSources) {
599
599
  includeSources(schema, sources);
600
600
  }
@@ -610,11 +610,12 @@ function loadSchemaSync(schemaPointers, options) {
610
610
  filterKinds: OPERATION_KINDS,
611
611
  ...options,
612
612
  });
613
- const { schemas, typeDefs } = collectSchemasAndTypeDefs(sources);
614
- const schema = mergeSchemas({
615
- schemas,
616
- typeDefs,
613
+ const { typeDefs, resolvers, schemaExtensions } = collectSchemaParts(sources);
614
+ const schema = makeExecutableSchema({
617
615
  ...options,
616
+ typeDefs,
617
+ resolvers,
618
+ schemaExtensions,
618
619
  });
619
620
  if (options === null || options === void 0 ? void 0 : options.includeSources) {
620
621
  includeSources(schema, sources);
@@ -637,20 +638,27 @@ function includeSources(schema, sources) {
637
638
  extendedSources: sources,
638
639
  };
639
640
  }
640
- function collectSchemasAndTypeDefs(sources) {
641
- const schemas = [];
641
+ function collectSchemaParts(sources) {
642
642
  const typeDefs = [];
643
+ const resolvers = [];
644
+ const schemaExtensions = [];
643
645
  for (const source of sources) {
644
646
  if (source.schema) {
645
- schemas.push(source.schema);
647
+ typeDefs.push(source.schema);
648
+ resolvers.push(getResolversFromSchema(source.schema));
649
+ schemaExtensions.push(extractExtensionsFromSchema(source.schema));
646
650
  }
647
- else if (source.document) {
648
- typeDefs.push(source.document);
651
+ else {
652
+ const typeDef = source.document || source.rawSDL;
653
+ if (typeDef) {
654
+ typeDefs.push(typeDef);
655
+ }
649
656
  }
650
657
  }
651
658
  return {
652
- schemas,
653
659
  typeDefs,
660
+ resolvers,
661
+ schemaExtensions,
654
662
  };
655
663
  }
656
664
 
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@graphql-tools/load",
3
- "version": "7.5.13",
3
+ "version": "7.5.14-alpha-950a29c9.0",
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/schema": "8.3.13",
10
+ "@graphql-tools/merge": "8.2.13",
11
+ "@graphql-tools/schema": "9.0.0-alpha-950a29c9.0",
11
12
  "@graphql-tools/utils": "8.6.12",
12
13
  "p-limit": "3.1.0",
13
14
  "tslib": "~2.4.0"
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 { MergeSchemasConfig } from '@graphql-tools/schema';
4
- export declare type LoadSchemaOptions = BuildSchemaOptions & LoadTypedefsOptions & Partial<MergeSchemasConfig> & {
3
+ import { IExecutableSchemaDefinition } from '@graphql-tools/schema';
4
+ export declare type LoadSchemaOptions = BuildSchemaOptions & LoadTypedefsOptions & Partial<IExecutableSchemaDefinition> & {
5
5
  /**
6
6
  * Adds a list of Sources in to `extensions.sources`
7
7
  *