@graphql-inspector/core
Advanced tools
Comparing version 0.8.0 to 0.9.0
@@ -34,3 +34,7 @@ "use strict"; | ||
.forEach(function (doc) { | ||
var merged = "\n " + doc.source.body + "\n\n " + (extractFragments(doc.source.body) || []) | ||
var docWithOperations = { | ||
kind: 'Document', | ||
definitions: doc.operations.map(function (d) { return d.node; }), | ||
}; | ||
var extractedFragments = (extractFragments(graphql_1.print(docWithOperations)) || []) | ||
// resolve all nested fragments | ||
@@ -45,16 +49,11 @@ .map(function (fragmentName) { | ||
return all.findIndex(function (item) { return item.name.value === def.name.value; }) === i; | ||
}) | ||
// does not include fragment definition | ||
.filter(function (fragment) { | ||
return doc.source.body.indexOf("fragment " + fragment.name.value + " on") === | ||
-1; | ||
}) | ||
.map(graphql_1.print) | ||
// merge | ||
.join('\n\n') + "\n "; | ||
var errors = graphql_1.validate(schema, graphql_1.parse(merged)); | ||
}); | ||
var merged = { | ||
kind: 'Document', | ||
definitions: docWithOperations.definitions.concat(extractedFragments), | ||
}; | ||
var errors = graphql_1.validate(schema, merged); | ||
var deprecated = graphql_2.findDeprecatedUsages(schema, graphql_1.parse(doc.source.body)); | ||
var duplicatedFragments = findDuplicatedFragments(fragmentNames); | ||
if (errors || deprecated || duplicatedFragments) { | ||
if (sumLengths(errors, duplicatedFragments, deprecated) > 0) { | ||
invalidDocuments.push({ | ||
@@ -89,2 +88,12 @@ source: doc.source, | ||
} | ||
function sumLengths() { | ||
var arrays = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
arrays[_i] = arguments[_i]; | ||
} | ||
return arrays.reduce(function (sum, _a) { | ||
var length = _a.length; | ||
return sum + length; | ||
}, 0); | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@graphql-inspector/core", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "Tooling for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
788007
1688