Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@graphql-inspector/core

Package Overview
Dependencies
Maintainers
1
Versions
420
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-inspector/core - npm Package Compare versions

Comparing version 0.7.2 to 0.7.3

yarn-error.log

58

dist/validate/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var graphql_1 = require("graphql");
var dependency_graph_1 = require("dependency-graph");
var document_1 = require("../ast/document");

@@ -12,15 +13,42 @@ var graphql_2 = require("../utils/graphql");

var fragments = [];
var graph = new dependency_graph_1.DepGraph({ circular: true });
documents.forEach(function (doc) {
doc.fragments.forEach(function (fragment) {
fragments.push(fragment.node);
fragments.push(fragment);
graph.addNode(fragment.node.name.value, fragment.node);
});
});
documents.forEach(function (doc) {
var errors = graphql_1.validate(schema,
// all fragments next to an operation? Stuuuupid
// but should be enough for now
graphql_1.parse("\n " + doc.source.body + "\n\n " + fragments
.filter(function (f) { return doc.source.body.indexOf("fragment " + f.name.value + " on"); })
fragments.forEach(function (fragment) {
var depends = extractFragments(graphql_1.print(fragment.node));
if (depends) {
depends.forEach(function (name) {
graph.addDependency(fragment.node.name.value, name);
});
}
});
documents
// since we include fragments, validate only operations
.filter(function (doc) { return doc.hasOperations; })
.forEach(function (doc) {
var merged = "\n " + doc.source.body + "\n\n " + (extractFragments(doc.source.body) || [])
// resolve all nested fragments
.map(function (fragmentName) {
return resolveFragment(graph.getNodeData(fragmentName), graph);
})
// flatten arrays
.reduce(function (list, current) { return list.concat(current); }, [])
// remove duplicates
.filter(function (def, i, all) {
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;
})
// print
.map(graphql_1.print)
.join('\n\n') + "\n "));
// merge
.join('\n\n') + "\n ";
var errors = graphql_1.validate(schema, graphql_1.parse(merged));
var deprecated = graphql_2.findDeprecatedUsages(schema, graphql_1.parse(doc.source.body));

@@ -38,2 +66,16 @@ if (errors || deprecated) {

exports.validate = validate;
//
// PostInfo -> AuthorInfo
// AuthorInfo -> None
//
function resolveFragment(fragment, graph) {
return graph
.dependenciesOf(fragment.name.value)
.reduce(function (list, current) { return list.concat(resolveFragment(graph.getNodeData(current), graph)); }, [fragment]);
}
function extractFragments(document) {
return (document.match(/[\.]{3}[a-z0-9\_]+\b/gi) || []).map(function (name) {
return name.replace('...', '');
});
}
//# sourceMappingURL=index.js.map

5

package.json
{
"name": "@graphql-inspector/core",
"version": "0.7.2",
"version": "0.7.3",
"description": "Tooling for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types.",

@@ -39,3 +39,6 @@ "keywords": [

"typescript": "3.2.2"
},
"dependencies": {
"dependency-graph": "0.8.0"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc