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

graphql-import

Package Overview
Dependencies
Maintainers
3
Versions
431
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-import - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

35

dist/index.js

@@ -58,3 +58,3 @@ "use strict";

var sdl = read(schema, schemas) || schema;
var document = graphql_1.parse(sdl, { noLocation: true });
var document = getDocumentFromSDL(sdl);
// Recursively process the imports, starting by importing all types from the initial schema

@@ -92,2 +92,33 @@ var _a = collectDefinitions(['*'], sdl, schema, schemas), allDefinitions = _a.allDefinitions, typeDefinitions = _a.typeDefinitions;

/**
* Parses a schema into a graphql DocumentNode.
* If the schema is empty a DocumentNode with empty definitions will be created.
*
* @param sdl Schema to parse
* @returns A graphql DocumentNode with definitions of the parsed sdl.
*/
function getDocumentFromSDL(sdl) {
if (isEmptySDL(sdl)) {
return {
kind: graphql_1.Kind.DOCUMENT,
definitions: [],
};
}
else {
return graphql_1.parse(sdl, { noLocation: true });
}
}
/**
* Check if a schema contains any type definitions at all.
*
* @param sdl Schema to parse
* @returns True if SDL only contains comments and/or whitespaces
*/
function isEmptySDL(sdl) {
return sdl
.split('\n')
.map(function (l) { return l.trim(); })
.filter(function (l) { return !(l.length === 0 || l.startsWith('#')); })
.length === 0;
}
/**
* Recursively process all schema files. Keeps track of both the filtered

@@ -112,3 +143,3 @@ * type definitions, and all type definitions, because they might be needed

// Get TypeDefinitionNodes from current schema
var document = graphql_1.parse(sdl);
var document = getDocumentFromSDL(sdl);
// Add all definitions to running total

@@ -115,0 +146,0 @@ allDefinitions.push(filterTypeDefinitions(document.definitions));

@@ -48,2 +48,6 @@ "use strict";

});
ava_1.default('importSchema: imports only', function (t) {
var expectedSDL = "type Query {\n first: String\n second: Float\n third: String\n}\n";
t.is(_1.importSchema('fixtures/imports-only/all.graphql'), expectedSDL);
});
ava_1.default('importSchema: field types', function (t) {

@@ -50,0 +54,0 @@ var expectedSDL = "type A {\n first: String\n second: Float\n b: B\n}\n\ntype B {\n c: C\n hello: String!\n}\n\ntype C {\n id: ID!\n}\n";

2

package.json
{
"name": "graphql-import",
"version": "0.4.0",
"version": "0.4.1",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": "git@github.com:graphcool/graphql-import.git",

Sorry, the diff of this file is not supported yet

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