@graphql-codegen/core 2.6.3 → 2.6.4-alpha-20221101150415-80570b2d4
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/codegen.js +6 -3
- package/esm/codegen.js +7 -4
- package/package.json +2 -2
package/cjs/codegen.js
CHANGED
|
@@ -60,15 +60,18 @@ async function codegen(options) {
|
|
|
60
60
|
const rules = graphql_1.specifiedRules.filter(rule => !ignored.some(ignoredRule => rule.name.startsWith(ignoredRule)));
|
|
61
61
|
const schemaHash = (0, utils_js_1.extractHashFromSchema)(schemaInstance);
|
|
62
62
|
if (!schemaHash || !options.cache || documents.some(d => typeof d.hash !== 'string')) {
|
|
63
|
-
return (0, utils_1.validateGraphQlDocuments)(schemaInstance, [...documents, ...fragments], rules);
|
|
63
|
+
return Promise.resolve((0, utils_1.validateGraphQlDocuments)(schemaInstance, [...documents.flatMap(d => d.document), ...fragments.flatMap(f => f.document)], rules));
|
|
64
64
|
}
|
|
65
65
|
const cacheKey = [schemaHash]
|
|
66
66
|
.concat(documents.map(doc => doc.hash))
|
|
67
67
|
.concat(JSON.stringify(fragments))
|
|
68
68
|
.join(',');
|
|
69
|
-
return options.cache('documents-validation', cacheKey, () => (0, utils_1.validateGraphQlDocuments)(schemaInstance, [...documents, ...fragments], rules));
|
|
69
|
+
return options.cache('documents-validation', cacheKey, () => Promise.resolve((0, utils_1.validateGraphQlDocuments)(schemaInstance, [...documents.flatMap(d => d.document), ...fragments.flatMap(f => f.document)], rules)));
|
|
70
70
|
}, 'Validate documents against schema');
|
|
71
|
-
|
|
71
|
+
if (errors.length > 0) {
|
|
72
|
+
throw new Error(`GraphQL Document Validation failed with ${errors.length} errors;
|
|
73
|
+
${errors.map((error, index) => `Error ${index}: ${error.stack}`).join('\n\n')}`);
|
|
74
|
+
}
|
|
72
75
|
}
|
|
73
76
|
const prepend = new Set();
|
|
74
77
|
const append = new Set();
|
package/esm/codegen.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isComplexPluginOutput, federationSpec, getCachedDocumentNodeFromSchema, createNoopProfiler, } from '@graphql-codegen/plugin-helpers';
|
|
2
2
|
import { visit, Kind, print, specifiedRules } from 'graphql';
|
|
3
3
|
import { executePlugin } from './execute-plugin.js';
|
|
4
|
-
import {
|
|
4
|
+
import { validateGraphQlDocuments, asArray } from '@graphql-tools/utils';
|
|
5
5
|
import { mergeSchemas } from '@graphql-tools/schema';
|
|
6
6
|
import { extractHashFromSchema, getSkipDocumentsValidationOption, hasFederationSpec, pickFlag, prioritize, shouldValidateDocumentsAgainstSchema, shouldValidateDuplicateDocuments, } from './utils.js';
|
|
7
7
|
export async function codegen(options) {
|
|
@@ -57,15 +57,18 @@ export async function codegen(options) {
|
|
|
57
57
|
const rules = specifiedRules.filter(rule => !ignored.some(ignoredRule => rule.name.startsWith(ignoredRule)));
|
|
58
58
|
const schemaHash = extractHashFromSchema(schemaInstance);
|
|
59
59
|
if (!schemaHash || !options.cache || documents.some(d => typeof d.hash !== 'string')) {
|
|
60
|
-
return validateGraphQlDocuments(schemaInstance, [...documents, ...fragments], rules);
|
|
60
|
+
return Promise.resolve(validateGraphQlDocuments(schemaInstance, [...documents.flatMap(d => d.document), ...fragments.flatMap(f => f.document)], rules));
|
|
61
61
|
}
|
|
62
62
|
const cacheKey = [schemaHash]
|
|
63
63
|
.concat(documents.map(doc => doc.hash))
|
|
64
64
|
.concat(JSON.stringify(fragments))
|
|
65
65
|
.join(',');
|
|
66
|
-
return options.cache('documents-validation', cacheKey, () => validateGraphQlDocuments(schemaInstance, [...documents, ...fragments], rules));
|
|
66
|
+
return options.cache('documents-validation', cacheKey, () => Promise.resolve(validateGraphQlDocuments(schemaInstance, [...documents.flatMap(d => d.document), ...fragments.flatMap(f => f.document)], rules)));
|
|
67
67
|
}, 'Validate documents against schema');
|
|
68
|
-
|
|
68
|
+
if (errors.length > 0) {
|
|
69
|
+
throw new Error(`GraphQL Document Validation failed with ${errors.length} errors;
|
|
70
|
+
${errors.map((error, index) => `Error ${index}: ${error.stack}`).join('\n\n')}`);
|
|
71
|
+
}
|
|
69
72
|
}
|
|
70
73
|
const prepend = new Set();
|
|
71
74
|
const append = new Set();
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/core",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.4-alpha-20221101150415-80570b2d4",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"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 || ^16.0.0"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@graphql-codegen/plugin-helpers": "^2.7.2",
|
|
9
9
|
"@graphql-tools/schema": "^9.0.0",
|
|
10
|
-
"@graphql-tools/utils": "
|
|
10
|
+
"@graphql-tools/utils": "9.0.0",
|
|
11
11
|
"tslib": "~2.4.0"
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|