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

@anchan828/gen-graphql-merge-schema

Package Overview
Dependencies
Maintainers
1
Versions
188
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@anchan828/gen-graphql-merge-schema - npm Package Compare versions

Comparing version 0.1.27 to 0.1.28

4

dist/index.js

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

const service = new service_1.MergeSchemaService();
types.forEach(type => service.cacheDescriptions(type));
types.forEach(type => service.cache(type));
let result = gen_graphql_order_schema_1.genOrderTypes(merge_graphql_schemas_1.mergeTypes([...types, `type Query`], {

@@ -20,4 +20,4 @@ all: true,

result = gen_graphql_relay_schema_1.genRelayTypes(result, options.relayOptions);
service.setDescriptions(result);
service.apply(result);
return graphql_1.printSchema(graphql_1.buildASTSchema(result));
};
import { DocumentNode } from 'graphql';
export declare class MergeSchemaService {
private descriptionMap;
cacheDescriptions(type: string | DocumentNode): void;
setDescriptions(type: DocumentNode): void;
private interfaceMap;
cache(type: string | DocumentNode): void;
apply(type: DocumentNode): void;
private cacheInterfaces;
private cacheDescriptions;
applyDescriptions(type: DocumentNode): void;
applyInterfaces(type: DocumentNode): void;
}

@@ -8,8 +8,34 @@ "use strict";

this.descriptionMap = new Map();
this.interfaceMap = new Map();
}
cacheDescriptions(type) {
cache(type) {
if (typeof type === 'string') {
type = graphql_1.parse(type);
}
this.cacheDescriptions(type);
this.cacheInterfaces(type);
}
apply(type) {
this.applyDescriptions(type);
this.applyInterfaces(type);
}
cacheInterfaces(type) {
for (const definition of gen_graphql_schema_common_1.getObjectTypeDefinitions(type)) {
if (!Array.isArray(definition.interfaces)) {
continue;
}
if (!this.interfaceMap.has(definition.name.value)) {
this.interfaceMap.set(definition.name.value, []);
}
const cachedInterfaces = this.interfaceMap.get(definition.name.value);
for (const interfaceDefinition of definition.interfaces) {
if (!cachedInterfaces.find(ci => interfaceDefinition.name.value === ci.name.value)) {
cachedInterfaces.push(interfaceDefinition);
}
}
this.interfaceMap.set(definition.name.value, cachedInterfaces);
}
}
cacheDescriptions(type) {
for (const definition of gen_graphql_schema_common_1.getObjectTypeDefinitions(type)) {
if (!(definition.description && definition.description.value)) {

@@ -28,3 +54,3 @@ continue;

}
setDescriptions(type) {
applyDescriptions(type) {
for (const definition of gen_graphql_schema_common_1.getObjectTypeDefinitions(type)) {

@@ -39,3 +65,20 @@ if (this.descriptionMap.has(definition.name.value)) {

}
applyInterfaces(type) {
for (const definition of gen_graphql_schema_common_1.getObjectTypeDefinitions(type)) {
if (this.interfaceMap.has(definition.name.value)) {
const interfaces = Object.assign([], definition.interfaces || []);
const cachedInterfaces = this.interfaceMap.get(definition.name.value);
if (!Array.isArray(cachedInterfaces)) {
continue;
}
for (const cachedInterface of cachedInterfaces) {
if (!interfaces.find((i) => i.name.value === cachedInterface.name.value)) {
interfaces.push(cachedInterface);
}
}
Reflect.set(definition, 'interfaces', interfaces);
}
}
}
}
exports.MergeSchemaService = MergeSchemaService;
{
"name": "@anchan828/gen-graphql-merge-schema",
"version": "0.1.27",
"version": "0.1.28",
"description": "merge multiple schema. merge-graphql-schemas based.",

@@ -43,3 +43,3 @@ "author": "anchan828 <anchan828@gmail.com>",

"homepage": "https://github.com/anchan828/gen-graphql-schema/tree/master/packages/merge-schema#readme",
"gitHead": "1c7b4c9262de3e0b16a827aff9fd0853e1c2522c"
"gitHead": "edb72b7e260dd54c1067d8b44f9c72a6e57a46a8"
}
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