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

graphql-import

Package Overview
Dependencies
Maintainers
1
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.1.3 to 0.1.4

28

dist/definition.js

@@ -38,6 +38,32 @@ "use strict";

}
if (newDefinition.kind === 'InterfaceTypeDefinition') {
newDefinition.fields.forEach(function (field) {
var namedType = getNamedType(field.type);
var typeName = namedType.name.value;
if (!definitionPool.some(function (d) { return d.name.value === typeName; }) &&
!builtinTypes.includes(typeName)) {
var schemaType = schemaMap[typeName];
if (!schemaType) {
throw new Error("Field " + field.name.value + ": Couldn't find type " + typeName + " in " + schemaPath + ".");
}
newTypeDefinitions.push(schemaType);
}
});
}
if (newDefinition.kind === 'UnionTypeDefinition') {
newDefinition.types.forEach(function (type) {
if (!definitionPool.some(function (d) { return d.name.value === type.name.value; })) {
var typeName = type.name.value;
var typeMatch = schemaMap[typeName];
if (!typeMatch) {
throw new Error("Couldn't find type " + typeName + " in " + schemaPath + ".");
}
newTypeDefinitions.push(schemaMap[type.name.value]);
}
});
}
if (newDefinition.kind === 'ObjectTypeDefinition') {
// collect missing interfaces
newDefinition.interfaces.forEach(function (int) {
if (!definitionPool.some(function (d) { return d.name === int.name; })) {
if (!definitionPool.some(function (d) { return d.name.value === int.name.value; })) {
var interfaceName = int.name.value;

@@ -44,0 +70,0 @@ var interfaceMatch = schemaMap[interfaceName];

@@ -54,4 +54,12 @@ "use strict";

});
ava_1.default('importSchema: unions', function (t) {
var expectedSDL = "type A {\n b: B\n}\n\nunion B = C1 | C2\n\ntype C1 {\n c1: ID\n}\n\ntype C2 {\n c2: ID\n}\n";
t.is(_1.importSchema('fixtures/unions/a.graphql'), expectedSDL);
});
ava_1.default('importSchema: scalar', function (t) {
var expectedSDL = "type A {\n b: B\n}\n\nscalar B\n";
t.is(_1.importSchema('fixtures/scalar/a.graphql'), expectedSDL);
});
ava_1.default('importSchema: interfaces', function (t) {
var expectedSDL = "type A implements B {\n first: String @first\n second: Float\n}\n\ninterface B {\n second: Float\n}\n";
var expectedSDL = "type A implements B {\n first: String @first\n second: Float\n}\n\ninterface B {\n second: Float\n c: [C!]!\n}\n\ntype C {\n c: ID!\n}\n";
t.is(_1.importSchema('fixtures/interfaces/a.graphql'), expectedSDL);

@@ -58,0 +66,0 @@ });

4

package.json
{
"name": "graphql-import",
"version": "0.1.3",
"version": "0.1.4",
"license": "MIT",

@@ -22,3 +22,3 @@ "repository": "git@github.com:graphcool/graphql-import.git",

"@types/node": "^8.0.53",
"ava": "^0.23.0",
"ava": "^0.24.0",
"tslint": "^5.8.0",

@@ -25,0 +25,0 @@ "tslint-config-standard": "^7.0.0",

@@ -61,4 +61,2 @@ # graphql-import [![Build Status](https://travis-ci.org/graphcool/graphql-import.svg?branch=master)](https://travis-ci.org/graphcool/graphql-import) [![npm version](https://badge.fury.io/js/graphql-import.svg)](https://badge.fury.io/js/graphql-import) [![Greenkeeper badge](https://badges.greenkeeper.io/graphcool/graphql-import.svg)](https://greenkeeper.io/)

```graphql
# import C from 'c.graphql'
type C {

@@ -92,4 +90,5 @@ id: ID!

- Static import step as build time
- Namespaces
- Support importing from HTTP endpoints (or [Links](https://github.com/apollographql/apollo-link))
- Create RFC to add import syntax to GraphQL spec
- Create RFC to add import syntax to GraphQL spec

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