Socket
Socket
Sign inDemoInstall

merge-graphql-schemas

Package Overview
Dependencies
Maintainers
2
Versions
269
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

merge-graphql-schemas - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

9

dist/merge_types.js

@@ -34,3 +34,3 @@ 'use strict';

var scalarTypeRegEx = /scalar ([\s\S]*?).*/gim;
var customTypeRegEx = /type (?!Query)(?!Mutation)([\s\S]*?) {/g;
var customTypeRegEx = /type (?!Query)(?!Mutation)(?!Subscription)([\s\S]*?) {/g;

@@ -64,9 +64,8 @@ var sliceTypes = function sliceTypes(regexp) {

var mutationTypes = sliceDefaultTypes('Mutation');
var subscriptionTypes = sliceDefaultTypes('Subscription');
var queryInterpolation = 'type Query {\n ' + queryTypes + '\n }';
var mutationInterpolation = 'type Mutation {\n ' + mutationTypes + '\n }';
var subscriptionInterpolation = 'type Subscription {\n ' + subscriptionTypes + '\n }';
var schema = '\n schema {\n query: Query\n ' + (mutationTypes !== '' ? 'mutation: Mutation\n' : '') + '\n ' + (subscriptionTypes !== '' ? 'subscription: Subscription\n' : '') + '\n }\n\n ' + (queryTypes !== '' ? queryInterpolation : '') + '\n\n ' + (mutationTypes !== '' ? mutationInterpolation : '') + '\n\n ' + (subscriptionTypes !== '' ? subscriptionInterpolation : '') + '\n ';
var schema = '\n schema {\n query: Query\n ' + (mutationTypes !== '' ? 'mutation: Mutation\n' : '') + '\n\n }\n\n ' + (queryTypes !== '' ? queryInterpolation : '') + '\n\n ' + (mutationTypes !== '' ? mutationInterpolation : '') + '\n ';
var mergedTypes = [];

@@ -73,0 +72,0 @@

{
"name": "merge-graphql-schemas",
"author": "OK GROW!",
"version": "0.0.9",
"version": "0.0.10",
"description": "Better organize your GraphQL server.",

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

@@ -19,3 +19,3 @@ import validateSchema from './validate_schema';

const scalarTypeRegEx = /scalar ([\s\S]*?).*/gim;
const customTypeRegEx = /type (?!Query)(?!Mutation)([\s\S]*?) {/g;
const customTypeRegEx = /type (?!Query)(?!Mutation)(?!Subscription)([\s\S]*?) {/g;

@@ -47,11 +47,12 @@ const sliceTypes = (regexp, scalar = false) => {

const mutationTypes = sliceDefaultTypes('Mutation');
const subscriptionTypes = sliceDefaultTypes('Subscription');
const queryInterpolation = `type Query {
${queryTypes}
}`;
const mutationInterpolation = `type Mutation {
${mutationTypes}
}`;
const subscriptionInterpolation = `type Subscription {
${subscriptionTypes}
}`;
const schema = `

@@ -61,3 +62,3 @@ schema {

${mutationTypes !== '' ? 'mutation: Mutation\n' : ''}
${subscriptionTypes !== '' ? 'subscription: Subscription\n' : ''}
}

@@ -68,2 +69,4 @@

${mutationTypes !== '' ? mutationInterpolation : ''}
${subscriptionTypes !== '' ? subscriptionInterpolation : ''}
`;

@@ -70,0 +73,0 @@

@@ -10,2 +10,6 @@ export default {

},
Subscriptions: {
activeClients: () => {},
inactiveClients: () => {},
},
Client: {

@@ -12,0 +16,0 @@ products: () => {},

@@ -10,2 +10,5 @@ export default {

},
Subscriptions: {
activeProducts: () => {},
},
Product: {

@@ -12,0 +15,0 @@ clients: () => {},

@@ -21,2 +21,7 @@ export default `

type Subscription {
activeClients: [Client]
inactiveClients: [Client]
}
input ClientForm {

@@ -23,0 +28,0 @@ name: String!

@@ -20,2 +20,6 @@ export default `

type Subscription {
activeProducts: [Product]
}
enum ProductTypes {

@@ -22,0 +26,0 @@ NEW

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

it('returns empty mutation type', async () => {
it('returns no mutation type', async () => {
const types = [];

@@ -57,2 +57,16 @@ const mergedTypes = mergeTypes(types);

});
it('returns no subscription type', async () => {
const types = [];
const mergedTypes = mergeTypes(types);
const expectedSchemaType = normalizeWhitespace(`
type Subscription {
}
`);
const schema = normalizeWhitespace(mergedTypes[0]);
assert.notInclude(schema, expectedSchemaType, 'Merged Schema is including empty subscription type');
});
});

@@ -91,3 +105,3 @@

it('returns empty mutation type', async () => {
it('returns no mutation type', async () => {
const types = [simpleQueryType];

@@ -105,2 +119,16 @@ const mergedTypes = mergeTypes(types);

});
it('returns no subscription type', async () => {
const types = [simpleQueryType];
const mergedTypes = mergeTypes(types);
const expectedSchemaType = normalizeWhitespace(`
type Subscription {
}
`);
const schema = normalizeWhitespace(mergedTypes[0]);
assert.notInclude(schema, expectedSchemaType, 'Merged simple Schema is including empty subscription type');
});
});

@@ -155,3 +183,3 @@

it('returns empty mutation type', async () => {
it('returns no mutation type', async () => {
const types = [customType];

@@ -167,7 +195,20 @@ const mergedTypes = mergeTypes(types);

assert.notInclude(schema, expectedSchemaType, 'Merged Schema is missing empty mutation type');
assert.notInclude(schema, expectedSchemaType, 'Merged Schema is including empty mutation type');
});
it('returns no subscription type', async () => {
const types = [customType];
const mergedTypes = mergeTypes(types);
const expectedSchemaType = normalizeWhitespace(`
type Subscription {
}
`);
const schema = normalizeWhitespace(mergedTypes[0]);
assert.notInclude(schema, expectedSchemaType, 'Merged Schema is including empty subscription type');
});
});
it('includes schemaType', async () => {

@@ -181,2 +222,3 @@ const types = [clientType, productType];

mutation: Mutation
subscription: Subscription
}

@@ -190,3 +232,2 @@ `);

it('includes queryType', async () => {

@@ -214,3 +255,4 @@ const types = [clientType, productType];

const expectedMutationType = normalizeWhitespace(`type Mutation {
const expectedMutationType = normalizeWhitespace(`
type Mutation {
create_client(name: String!, age: Int!): Client

@@ -228,2 +270,18 @@ update_client(id: ID!, name: String!, age: Int!): Client

it('includes subscriptionType', async () => {
const types = [clientType, productType];
const mergedTypes = mergeTypes(types);
const expectedSubscriptionType = normalizeWhitespace(`
type Subscription {
activeClients: [Client]
inactiveClients: [Client]
activeProducts: [Product]
}`);
const schema = normalizeWhitespace(mergedTypes[0]);
assert.include(schema, expectedSubscriptionType, 'Merged Schema is missing subscriptionType');
});
it('includes clientType', async () => {

@@ -230,0 +288,0 @@ const types = [clientType, productType];

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