Socket
Socket
Sign inDemoInstall

merge-graphql-schemas

Package Overview
Dependencies
5
Maintainers
2
Versions
269
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.7 to 0.0.8

test/graphql/other/custom_type.js

3

dist/file_loader.js

@@ -21,2 +21,5 @@ 'use strict';

_fs2.default.readdirSync(dir).forEach(function (f) {
if (f.slice(-3) !== '.js') {
return;
}
var filesDir = _path2.default.join(dir, f);

@@ -23,0 +26,0 @@ var file = require(filesDir); // eslint-disable-line

2

package.json
{
"name": "merge-graphql-schemas",
"author": "OK GROW!",
"version": "0.0.7",
"version": "0.0.8",
"description": "Better organize your GraphQL server.",

@@ -6,0 +6,0 @@ "repository": {

@@ -1,2 +0,2 @@

[![Build Status](https://semaphoreci.com/api/v1/rodmac98/merge-graphql-schemas/branches/master/shields_badge.svg)](https://semaphoreci.com/rodmac98/merge-graphql-schemas)
[![Build Status](https://semaphoreci.com/api/v1/okgrow/merge-graphql-schemas/branches/master/shields_badge.svg)](https://semaphoreci.com/okgrow/merge-graphql-schemas)

@@ -3,0 +3,0 @@

@@ -8,2 +8,3 @@ import fs from 'fs';

fs.readdirSync(dir).forEach((f) => {
if (f.slice(-3) !== '.js') { return; }
const filesDir = path.join(dir, f);

@@ -10,0 +11,0 @@ const file = require(filesDir); // eslint-disable-line

@@ -5,2 +5,3 @@ import chai from 'chai'; // eslint-disable-line

import productType from './graphql/types/product_type';
import customType from './graphql/other/custom_type';

@@ -12,5 +13,5 @@ const assert = chai.assert;

describe('mergeTypes', () => {
describe('with default options', () => {
it('includes schemaType', async () => {
const types = [clientType, productType];
describe('when no types exist', () => {
it('returns minimal schema', async () => {
const types = [];
const mergedTypes = mergeTypes(types);

@@ -28,15 +29,11 @@

assert.include(schema, expectedSchemaType, 'Merged Schema is missing schemaType');
});
it('includes queryType', async () => {
const types = [clientType, productType];
it('returns empty query type', async () => {
const types = [];
const mergedTypes = mergeTypes(types);
const expectedQueryType = normalizeWhitespace(`
const expectedSchemaType = normalizeWhitespace(`
type Query {
clients: [Client]
client(id: ID!): Client
products: [Product]
product(id: ID!): Product
}

@@ -47,32 +44,32 @@ `);

assert.include(schema, expectedQueryType, 'Merged Schema is missing queryType');
assert.include(schema, expectedSchemaType, 'Merged Schema is missing empty query type');
});
it('includes mutationType', async () => {
const types = [clientType, productType];
it('returns empty mutation type', async () => {
const types = [];
const mergedTypes = mergeTypes(types);
const expectedMutationType = normalizeWhitespace(`type Mutation {
create_client(name: String!, age: Int!): Client
update_client(id: ID!, name: String!, age: Int!): Client
create_product(description: String!, price: Int!): Product
update_product(id: ID!, description: String!, price: Int!): Product
}`);
const expectedSchemaType = normalizeWhitespace(`
type Mutation {
}
`);
const schema = normalizeWhitespace(mergedTypes[0]);
assert.include(schema, expectedMutationType, 'Merged Schema is missing mutationType');
assert.include(schema, expectedSchemaType, 'Merged Schema is missing empty mutation type');
});
});
it('includes clientType', async () => {
const types = [clientType, productType];
describe('when only single custom type is passed', () => {
it('includes customType', async () => {
const types = [customType];
const mergedTypes = mergeTypes(types);
const expectedClientType = normalizeWhitespace(`
type Client {
const expectedCustomType = normalizeWhitespace(`
type Custom {
id: ID!
name: String
age: Int
products: [Product]
}

@@ -83,23 +80,141 @@ `);

assert.include(separateTypes, expectedClientType, 'Merged Schema is missing clientType');
assert.include(separateTypes, expectedCustomType, 'Merged Schema is missing customType');
});
it('includes productType', async () => {
const types = [clientType, productType];
it('returns minimal schema', async () => {
const types = [customType];
const mergedTypes = mergeTypes(types);
const expectedProductType = normalizeWhitespace(`
type Product {
id: ID!
description: String
price: Int
clients: [Client]
const expectedSchemaType = normalizeWhitespace(`
schema {
query: Query,
mutation: Mutation
}
`);
const separateTypes = mergedTypes.slice(1).map(type => normalizeWhitespace(type));
const schema = normalizeWhitespace(mergedTypes[0]);
assert.include(separateTypes, expectedProductType, 'Merged Schema is missing productType');
assert.include(schema, expectedSchemaType, 'Merged Schema is missing schemaType');
});
it('returns empty query type', async () => {
const types = [customType];
const mergedTypes = mergeTypes(types);
const expectedSchemaType = normalizeWhitespace(`
type Query {
}
`);
const schema = normalizeWhitespace(mergedTypes[0]);
assert.include(schema, expectedSchemaType, 'Merged Schema is missing empty query type');
});
it('returns empty mutation type', async () => {
const types = [customType];
const mergedTypes = mergeTypes(types);
const expectedSchemaType = normalizeWhitespace(`
type Mutation {
}
`);
const schema = normalizeWhitespace(mergedTypes[0]);
assert.include(schema, expectedSchemaType, 'Merged Schema is missing empty mutation type');
});
});
it('includes schemaType', async () => {
const types = [clientType, productType];
const mergedTypes = mergeTypes(types);
const expectedSchemaType = normalizeWhitespace(`
schema {
query: Query,
mutation: Mutation
}
`);
const schema = normalizeWhitespace(mergedTypes[0]);
assert.include(schema, expectedSchemaType, 'Merged Schema is missing schemaType');
});
it('includes queryType', async () => {
const types = [clientType, productType];
const mergedTypes = mergeTypes(types);
const expectedQueryType = normalizeWhitespace(`
type Query {
clients: [Client]
client(id: ID!): Client
products: [Product]
product(id: ID!): Product
}
`);
const schema = normalizeWhitespace(mergedTypes[0]);
assert.include(schema, expectedQueryType, 'Merged Schema is missing queryType');
});
it('includes mutationType', async () => {
const types = [clientType, productType];
const mergedTypes = mergeTypes(types);
const expectedMutationType = normalizeWhitespace(`type Mutation {
create_client(name: String!, age: Int!): Client
update_client(id: ID!, name: String!, age: Int!): Client
create_product(description: String!, price: Int!): Product
update_product(id: ID!, description: String!, price: Int!): Product
}`);
const schema = normalizeWhitespace(mergedTypes[0]);
assert.include(schema, expectedMutationType, 'Merged Schema is missing mutationType');
});
it('includes clientType', async () => {
const types = [clientType, productType];
const mergedTypes = mergeTypes(types);
const expectedClientType = normalizeWhitespace(`
type Client {
id: ID!
name: String
age: Int
products: [Product]
}
`);
const separateTypes = mergedTypes.slice(1).map(type => normalizeWhitespace(type));
assert.include(separateTypes, expectedClientType, 'Merged Schema is missing clientType');
});
it('includes productType', async () => {
const types = [clientType, productType];
const mergedTypes = mergeTypes(types);
const expectedProductType = normalizeWhitespace(`
type Product {
id: ID!
description: String
price: Int
clients: [Client]
}
`);
const separateTypes = mergedTypes.slice(1).map(type => normalizeWhitespace(type));
assert.include(separateTypes, expectedProductType, 'Merged Schema is missing productType');
});
});
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc