@graphql-tools/load 7.5.12-alpha-565a0007.0 → 7.5.12
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 +15 -23
- package/index.mjs +16 -24
- package/package.json +3 -4
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,17 +608,18 @@ 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
|
-
const {
|
|
617
|
-
const
|
|
616
|
+
const { schemas, typeDefs } = collectSchemasAndTypeDefs(sources);
|
|
617
|
+
const mergeSchemasOptions = {
|
|
618
618
|
...options,
|
|
619
|
+
schemas: schemas.concat((_a = options.schemas) !== null && _a !== void 0 ? _a : []),
|
|
619
620
|
typeDefs,
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
});
|
|
621
|
+
};
|
|
622
|
+
const schema$1 = schema.mergeSchemas(mergeSchemasOptions);
|
|
623
623
|
if (options === null || options === void 0 ? void 0 : options.includeSources) {
|
|
624
624
|
includeSources(schema$1, sources);
|
|
625
625
|
}
|
|
@@ -635,12 +635,11 @@ function loadSchemaSync(schemaPointers, options) {
|
|
|
635
635
|
filterKinds: OPERATION_KINDS,
|
|
636
636
|
...options,
|
|
637
637
|
});
|
|
638
|
-
const {
|
|
638
|
+
const { schemas, typeDefs } = collectSchemasAndTypeDefs(sources);
|
|
639
639
|
const schema$1 = schema.mergeSchemas({
|
|
640
|
-
|
|
640
|
+
schemas,
|
|
641
641
|
typeDefs,
|
|
642
|
-
|
|
643
|
-
schemaExtensions,
|
|
642
|
+
...options,
|
|
644
643
|
});
|
|
645
644
|
if (options === null || options === void 0 ? void 0 : options.includeSources) {
|
|
646
645
|
includeSources(schema$1, sources);
|
|
@@ -663,27 +662,20 @@ function includeSources(schema, sources) {
|
|
|
663
662
|
extendedSources: sources,
|
|
664
663
|
};
|
|
665
664
|
}
|
|
666
|
-
function
|
|
665
|
+
function collectSchemasAndTypeDefs(sources) {
|
|
666
|
+
const schemas = [];
|
|
667
667
|
const typeDefs = [];
|
|
668
|
-
const resolvers = [];
|
|
669
|
-
const schemaExtensions = [];
|
|
670
668
|
for (const source of sources) {
|
|
671
669
|
if (source.schema) {
|
|
672
|
-
|
|
673
|
-
resolvers.push(utils.getResolversFromSchema(source.schema));
|
|
674
|
-
schemaExtensions.push(merge.extractExtensionsFromSchema(source.schema));
|
|
670
|
+
schemas.push(source.schema);
|
|
675
671
|
}
|
|
676
|
-
else {
|
|
677
|
-
|
|
678
|
-
if (typeDef) {
|
|
679
|
-
typeDefs.push(typeDef);
|
|
680
|
-
}
|
|
672
|
+
else if (source.document) {
|
|
673
|
+
typeDefs.push(source.document);
|
|
681
674
|
}
|
|
682
675
|
}
|
|
683
676
|
return {
|
|
677
|
+
schemas,
|
|
684
678
|
typeDefs,
|
|
685
|
-
resolvers,
|
|
686
|
-
schemaExtensions,
|
|
687
679
|
};
|
|
688
680
|
}
|
|
689
681
|
|
package/index.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { asArray, AggregateError, isDocumentString, parseGraphQLSDL, getDocumentNodeFromSchema, printSchemaWithDirectives, printWithComments, resetComments, compareStrings
|
|
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,17 +583,18 @@ 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
|
-
const {
|
|
592
|
-
const
|
|
591
|
+
const { schemas, typeDefs } = collectSchemasAndTypeDefs(sources);
|
|
592
|
+
const mergeSchemasOptions = {
|
|
593
593
|
...options,
|
|
594
|
+
schemas: schemas.concat((_a = options.schemas) !== null && _a !== void 0 ? _a : []),
|
|
594
595
|
typeDefs,
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
});
|
|
596
|
+
};
|
|
597
|
+
const schema = mergeSchemas(mergeSchemasOptions);
|
|
598
598
|
if (options === null || options === void 0 ? void 0 : options.includeSources) {
|
|
599
599
|
includeSources(schema, sources);
|
|
600
600
|
}
|
|
@@ -610,12 +610,11 @@ function loadSchemaSync(schemaPointers, options) {
|
|
|
610
610
|
filterKinds: OPERATION_KINDS,
|
|
611
611
|
...options,
|
|
612
612
|
});
|
|
613
|
-
const {
|
|
613
|
+
const { schemas, typeDefs } = collectSchemasAndTypeDefs(sources);
|
|
614
614
|
const schema = mergeSchemas({
|
|
615
|
-
|
|
615
|
+
schemas,
|
|
616
616
|
typeDefs,
|
|
617
|
-
|
|
618
|
-
schemaExtensions,
|
|
617
|
+
...options,
|
|
619
618
|
});
|
|
620
619
|
if (options === null || options === void 0 ? void 0 : options.includeSources) {
|
|
621
620
|
includeSources(schema, sources);
|
|
@@ -638,27 +637,20 @@ function includeSources(schema, sources) {
|
|
|
638
637
|
extendedSources: sources,
|
|
639
638
|
};
|
|
640
639
|
}
|
|
641
|
-
function
|
|
640
|
+
function collectSchemasAndTypeDefs(sources) {
|
|
641
|
+
const schemas = [];
|
|
642
642
|
const typeDefs = [];
|
|
643
|
-
const resolvers = [];
|
|
644
|
-
const schemaExtensions = [];
|
|
645
643
|
for (const source of sources) {
|
|
646
644
|
if (source.schema) {
|
|
647
|
-
|
|
648
|
-
resolvers.push(getResolversFromSchema(source.schema));
|
|
649
|
-
schemaExtensions.push(extractExtensionsFromSchema(source.schema));
|
|
645
|
+
schemas.push(source.schema);
|
|
650
646
|
}
|
|
651
|
-
else {
|
|
652
|
-
|
|
653
|
-
if (typeDef) {
|
|
654
|
-
typeDefs.push(typeDef);
|
|
655
|
-
}
|
|
647
|
+
else if (source.document) {
|
|
648
|
+
typeDefs.push(source.document);
|
|
656
649
|
}
|
|
657
650
|
}
|
|
658
651
|
return {
|
|
652
|
+
schemas,
|
|
659
653
|
typeDefs,
|
|
660
|
-
resolvers,
|
|
661
|
-
schemaExtensions,
|
|
662
654
|
};
|
|
663
655
|
}
|
|
664
656
|
|
package/package.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/load",
|
|
3
|
-
"version": "7.5.12
|
|
3
|
+
"version": "7.5.12",
|
|
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"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@graphql-tools/
|
|
11
|
-
"@graphql-tools/
|
|
12
|
-
"@graphql-tools/utils": "8.6.10",
|
|
10
|
+
"@graphql-tools/schema": "8.3.12",
|
|
11
|
+
"@graphql-tools/utils": "8.6.11",
|
|
13
12
|
"p-limit": "3.1.0",
|
|
14
13
|
"tslib": "~2.4.0"
|
|
15
14
|
},
|