New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

graphql-compose-modules

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-compose-modules - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

4

lib/astToSchema.d.ts

@@ -5,5 +5,7 @@ import { SchemaComposer, ObjectTypeComposer } from 'graphql-compose';

schemaComposer?: SchemaComposer<any>;
prefix?: string;
suffix?: string;
}
export declare function astToSchema<TContext = any>(ast: AstResult, opts?: AstOptions): SchemaComposer<TContext>;
export declare function createFields(sc: SchemaComposer<any>, ast: AstDirNode | AstFileNode | void, prefix: string, parent: ObjectTypeComposer): void;
export declare function createFields(sc: SchemaComposer<any>, ast: AstDirNode | AstFileNode | void, parent: ObjectTypeComposer, pathPrefix: string, opts?: AstOptions): void;
//# sourceMappingURL=astToSchema.d.ts.map

@@ -38,18 +38,19 @@ "use strict";

if (ast.query)
populateRoot(sc, 'Query', ast.query);
populateRoot(sc, 'Query', ast.query, opts);
if (ast.mutation)
populateRoot(sc, 'Mutation', ast.mutation);
populateRoot(sc, 'Mutation', ast.mutation, opts);
if (ast.subscription)
populateRoot(sc, 'Subscription', ast.subscription);
populateRoot(sc, 'Subscription', ast.subscription, opts);
return sc;
}
exports.astToSchema = astToSchema;
function populateRoot(sc, rootName, astRootNode) {
function populateRoot(sc, rootName, astRootNode, opts) {
var tc = sc[rootName];
Object.keys(astRootNode.children).forEach(function (key) {
createFields(sc, astRootNode.children[key], rootName, tc);
createFields(sc, astRootNode.children[key], tc, rootName, opts || {});
});
}
function createFields(sc, ast, prefix, parent) {
function createFields(sc, ast, parent, pathPrefix, opts) {
var _a, _b, _c;
if (opts === void 0) { opts = {}; }
if (!ast)

@@ -66,3 +67,3 @@ return;

parent.addNestedFields((_a = {},
_a[fieldName] = prepareNamespaceFieldConfig(sc, ast, "" + prefix + getTypename(ast)),
_a[fieldName] = prepareNamespaceFieldConfig(sc, ast, getTypename(ast, pathPrefix, opts)),
_a));

@@ -79,9 +80,9 @@ }

if (ast.kind === 'dir') {
var typename_1 = "" + prefix + getTypename(ast);
var typename = getTypename(ast, pathPrefix, opts);
var fc_1;
if (ast.children['index'] && ast.children['index'].kind === 'file') {
fc_1 = prepareNamespaceFieldConfig(sc, ast.children['index'], typename_1);
fc_1 = prepareNamespaceFieldConfig(sc, ast.children['index'], typename);
}
else {
fc_1 = { type: sc.createObjectTC(typename_1) };
fc_1 = { type: sc.createObjectTC(typename) };
}

@@ -91,4 +92,5 @@ parent.addNestedFields((_c = {},

_c));
var pathPrefixForChild_1 = getTypename(ast, pathPrefix, {});
Object.keys(ast.children).forEach(function (key) {
createFields(sc, ast.children[key], typename_1, fc_1.type);
createFields(sc, ast.children[key], fc_1.type, pathPrefixForChild_1, opts);
});

@@ -98,4 +100,5 @@ }

exports.createFields = createFields;
function getTypename(ast) {
function getTypename(ast, pathPrefix, opts) {
var name = ast.name;
var typename = pathPrefix;
if (name.indexOf('.') !== -1) {

@@ -106,3 +109,3 @@ var namesArray = name.split('.');

}
return namesArray.reduce(function (prev, current) {
typename += namesArray.reduce(function (prev, current) {
return prev + graphql_compose_1.upperFirst(current);

@@ -112,4 +115,9 @@ }, '');

else {
return graphql_compose_1.upperFirst(name);
typename += graphql_compose_1.upperFirst(name);
}
if (opts.prefix)
typename = "" + opts.prefix + typename;
if (opts.suffix)
typename += opts.suffix;
return typename;
}

@@ -116,0 +124,0 @@ function prepareNamespaceFieldConfig(sc, ast, typename) {

{
"name": "graphql-compose-modules",
"license": "MIT",
"version": "1.0.2",
"version": "1.1.0",
"description": "A toolset for construction GraphQL Schema via file structure",

@@ -14,3 +14,3 @@ "repository": "https://github.com/graphql-compose/graphql-compose-modules",

"dependencies": {
"dedent": "^0.7.0"
"dedent": "0.7.0"
},

@@ -17,0 +17,0 @@ "peerDependencies": {

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