Socket
Socket
Sign inDemoInstall

graphile-build

Package Overview
Dependencies
Maintainers
1
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphile-build - npm Package Compare versions

Comparing version 4.0.0-rc.9 to 4.0.0-rc.10

node8plus/plugins/SwallowErrorsPlugin.js

41

node8plus/extend.js

@@ -6,19 +6,58 @@ "use strict";

});
exports.indent = indent;
exports.default = extend;
var _chalk = require("chalk");
var _chalk2 = _interopRequireDefault(_chalk);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const aExtendedB = new WeakMap();
const INDENT = " ";
function indent(text) {
return INDENT + text.replace(/\n/g, "\n" + INDENT).replace(/\n +(?=\n|$)/g, "\n");
}
function extend(base, extra, hint) {
const keysA = Object.keys(base);
const keysB = Object.keys(extra);
const hints = Object.create(null);
for (const key of keysA) {
const hintKey = `_source__${key}`;
if (base[hintKey]) {
hints[hintKey] = base[hintKey];
}
}
for (const key of keysB) {
const newValue = extra[key];
const oldValue = base[key];
const hintKey = `_source__${key}`;
const hintB = extra[hintKey] || hint;
if (aExtendedB.get(newValue) !== oldValue && keysA.indexOf(key) >= 0) {
throw new Error(`Overwriting key '${key}' is not allowed! ${hint || ""}`);
// $FlowFixMe
const hintA = base[hintKey];
const firstEntityDetails = !hintA ? "We don't have any information about the first entity." : `The first entity was:\n\n${indent(_chalk2.default.magenta(hintA))}`;
const secondEntityDetails = !hintB ? "We don't have any information about the second entity." : `The second entity was:\n\n${indent(_chalk2.default.yellow(hintB))}`;
throw new Error(`A naming conflict has occurred - two entities have tried to define the same key '${_chalk2.default.bold(key)}'.\n\n${indent(firstEntityDetails)}\n\n${indent(secondEntityDetails)}`);
}
hints[hintKey] = hints[hintKey] || hintB || base[hintKey];
}
const obj = Object.assign({}, base, extra);
aExtendedB.set(obj, base);
for (const hintKey in hints) {
if (hints[hintKey]) {
Object.defineProperty(obj, hintKey, {
configurable: false,
enumerable: false,
value: hints[hintKey],
writable: false
});
}
}
return obj;
}
//# sourceMappingURL=extend.js.map

5

node8plus/index.js

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

});
exports.resolveNode = exports.MutationPayloadQueryPlugin = exports.ClientMutationIdDescriptionPlugin = exports.SubscriptionPlugin = exports.MutationPlugin = exports.QueryPlugin = exports.NodePlugin = exports.StandardTypesPlugin = exports.defaultPlugins = exports.buildSchema = exports.getBuilder = exports.singularize = exports.pluralize = exports.upperCamelCase = exports.constantCase = exports.camelCase = exports.upperFirst = exports.formatInsideUnderscores = exports.constantCaseAll = undefined;
exports.resolveNode = exports.MutationPayloadQueryPlugin = exports.ClientMutationIdDescriptionPlugin = exports.SubscriptionPlugin = exports.MutationPlugin = exports.QueryPlugin = exports.NodePlugin = exports.StandardTypesPlugin = exports.SwallowErrorsPlugin = exports.defaultPlugins = exports.buildSchema = exports.getBuilder = exports.singularize = exports.pluralize = exports.upperCamelCase = exports.constantCase = exports.camelCase = exports.upperFirst = exports.formatInsideUnderscores = exports.constantCaseAll = undefined;

@@ -95,4 +95,5 @@ var _utils = require("./utils");

const defaultPlugins = exports.defaultPlugins = [_plugins.StandardTypesPlugin, _plugins.NodePlugin, _plugins.QueryPlugin, _plugins.MutationPlugin, _plugins.SubscriptionPlugin, _plugins.ClientMutationIdDescriptionPlugin, _plugins.MutationPayloadQueryPlugin];
const defaultPlugins = exports.defaultPlugins = [_plugins.SwallowErrorsPlugin, _plugins.StandardTypesPlugin, _plugins.NodePlugin, _plugins.QueryPlugin, _plugins.MutationPlugin, _plugins.SubscriptionPlugin, _plugins.ClientMutationIdDescriptionPlugin, _plugins.MutationPayloadQueryPlugin];
exports.SwallowErrorsPlugin = _plugins.SwallowErrorsPlugin;
exports.StandardTypesPlugin = _plugins.StandardTypesPlugin;

@@ -99,0 +100,0 @@ exports.NodePlugin = _plugins.NodePlugin;

@@ -40,2 +40,6 @@ "use strict";

var _chalk = require("chalk");
var _chalk2 = _interopRequireDefault(_chalk);
var _crypto = require("crypto");

@@ -50,3 +54,2 @@

const isString = str => typeof str === "string";
const isDev = ["test", "development"].indexOf(process.env.NODE_ENV) >= 0;

@@ -184,2 +187,9 @@ const debug = (0, _debug2.default)("graphile-build");

};
const allTypesSources = {
Int: "GraphQL Built-in",
Float: "GraphQL Built-in",
String: "GraphQL Built-in",
Boolean: "GraphQL Built-in",
ID: "GraphQL Built-in"
};

@@ -213,10 +223,20 @@ // Every object type gets fieldData associated with each of its

},
addType(type) {
addType(type, origin) {
if (!type.name) {
throw new Error(`addType must only be called with named types, try using require('graphql').getNamedType`);
}
if (allTypes[type.name] && allTypes[type.name] !== type) {
throw new Error(`There's already a type with the name: ${type.name}`);
const newTypeSource = origin || (
// 'this' is typically only available after the build is finalized
this ? `'addType' call during hook '${this.status.currentHookName}'` : null);
if (allTypes[type.name]) {
if (allTypes[type.name] !== type) {
const oldTypeSource = allTypesSources[type.name];
const firstEntityDetails = !oldTypeSource ? "The first type was registered from an unknown origin." : `The first entity was:\n\n${(0, _extend.indent)(_chalk2.default.magenta(oldTypeSource))}`;
const secondEntityDetails = !newTypeSource ? "The second type was registered from an unknown origin." : `The second entity was:\n\n${(0, _extend.indent)(_chalk2.default.yellow(newTypeSource))}`;
throw new Error(`A type naming conflict has occurred - two entities have tried to define the same type '${_chalk2.default.bold(type.name)}'.\n\n${(0, _extend.indent)(firstEntityDetails)}\n\n${(0, _extend.indent)(secondEntityDetails)}`);
}
} else {
allTypes[type.name] = type;
allTypesSources[type.name] = newTypeSource;
}
allTypes[type.name] = type;
},

@@ -409,3 +429,3 @@ getTypeByName(typeName) {

}
const fieldsSpec = builder.applyHooks(this, "GraphQLObjectType:fields", rawFields, fieldsContext, `|${rawSpec.name}`);
const fieldsSpec = builder.applyHooks(this, "GraphQLObjectType:fields", this.extend({}, rawFields, `Default field included in newWithHooks call for '${rawSpec.name}'. ${inScope.__origin || ""}`), fieldsContext, `|${rawSpec.name}`);
// Finally, check through all the fields that they've all been processed; any that have not we should do so now.

@@ -463,3 +483,3 @@ for (const fieldName in fieldsSpec) {

}
const fieldsSpec = builder.applyHooks(this, "GraphQLInputObjectType:fields", rawFields, fieldsContext, `|${getNameFromType(Self)}`);
const fieldsSpec = builder.applyHooks(this, "GraphQLInputObjectType:fields", this.extend({}, rawFields, `Default field included in newWithHooks call for '${rawSpec.name}'. ${inScope.__origin || ""}`), fieldsContext, `|${getNameFromType(Self)}`);
// Finally, check through all the fields that they've all been processed; any that have not we should do so now.

@@ -524,6 +544,3 @@ for (const fieldName in fieldsSpec) {

if (finalSpec.name) {
if (allTypes[finalSpec.name]) {
throw new Error(`Type '${finalSpec.name}' has already been registered!`);
}
allTypes[finalSpec.name] = Self;
this.addType(Self, scope.__origin || (this ? `'newWithHooks' call during hook '${this.status.currentHookName}'` : null));
}

@@ -546,5 +563,9 @@ fieldDataGeneratorsByFieldNameByType.set(Self, fieldDataGeneratorsByFieldName);

// resolveNode: EXPERIMENTAL, API might change!
resolveNode: _resolveNode2.default
resolveNode: _resolveNode2.default,
status: {
currentHookName: null,
currentHookEvent: null
}
};
}
//# sourceMappingURL=makeNewBuild.js.map

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

});
exports.StandardTypesPlugin = exports.QueryPlugin = exports.NodePlugin = exports.SubscriptionPlugin = exports.MutationPlugin = exports.MutationPayloadQueryPlugin = exports.ClientMutationIdDescriptionPlugin = undefined;
exports.SwallowErrorsPlugin = exports.StandardTypesPlugin = exports.QueryPlugin = exports.NodePlugin = exports.SubscriptionPlugin = exports.MutationPlugin = exports.MutationPayloadQueryPlugin = exports.ClientMutationIdDescriptionPlugin = undefined;

@@ -37,2 +37,6 @@ var _ClientMutationIdDescriptionPlugin = require("./ClientMutationIdDescriptionPlugin");

var _SwallowErrorsPlugin = require("./SwallowErrorsPlugin");
var _SwallowErrorsPlugin2 = _interopRequireDefault(_SwallowErrorsPlugin);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -47,2 +51,3 @@

exports.StandardTypesPlugin = _StandardTypesPlugin2.default;
exports.SwallowErrorsPlugin = _SwallowErrorsPlugin2.default;
//# sourceMappingURL=index.js.map

@@ -32,7 +32,10 @@ "use strict";

description: "The root mutation type which contains root level fields which mutate data."
}, { isRootMutation: true }, true);
}, {
__origin: `graphile-build built-in (root mutation type)`,
isRootMutation: true
}, true);
if (isValidMutation(Mutation)) {
return extend(schema, {
mutation: Mutation
});
}, "Adding mutation type to schema");
} else {

@@ -39,0 +42,0 @@ return schema;

@@ -87,3 +87,5 @@ "use strict";

}
}, {});
}, {
__origin: `graphile-build built-in (NodePlugin); you can omit this plugin if you like, but you'll lose compatibility with Relay`
});
return _;

@@ -145,5 +147,5 @@ });

})
}, `Adding node helpers to the root Query`);
}, `Adding Relay Global Object Identification support to the root Query via 'node' and '${nodeIdFieldName}' fields`);
});
};
//# sourceMappingURL=NodePlugin.js.map

@@ -31,3 +31,6 @@ "use strict";

})
}, { isRootQuery: true }, true);
}, {
__origin: `graphile-build built-in (root query type)`,
isRootQuery: true
}, true);
if (queryType) {

@@ -34,0 +37,0 @@ return extend(schema, {

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

const Cursor = stringType("Cursor", "A location in a connection that can be used for resuming pagination.");
build.addType(Cursor);
build.addType(Cursor, "graphile-build built-in");
return build;

@@ -65,2 +65,3 @@ });

}, {
__origin: `graphile-build built-in`,
isPageInfo: true

@@ -67,0 +68,0 @@ });

@@ -32,7 +32,10 @@ "use strict";

description: "The root subscription type which contains root level fields which mutate data."
}, { isRootSubscription: true }, true);
}, {
__origin: `graphile-build built-in (root subscription type)`,
isRootSubscription: true
}, true);
if (isValidSubscription(Subscription)) {
return extend(schema, {
subscription: Subscription
});
}, "Adding subscription type to schema");
} else {

@@ -39,0 +42,0 @@ return schema;

@@ -147,3 +147,11 @@ "use strict";

debug(`${INDENT.repeat(this.depth)}[${hookName}${debugStr}]: Executing '${hookDisplayName}'`);
const previousHookName = build.status.currentHookName;
const previousHookEvent = build.status.currentHookEvent;
build.status.currentHookName = hookDisplayName;
build.status.currentHookEvent = hookName;
newObj = hook(newObj, build, context);
build.status.currentHookName = previousHookName;
build.status.currentHookEvent = previousHookEvent;
if (!newObj) {

@@ -193,3 +201,6 @@ throw new Error(`Hook '${hook.displayName || hook.name || "anonymous"}' for '${hookName}' returned falsy value '${newObj}'`);

const build = this.createBuild();
this._generatedSchema = build.newWithHooks(GraphQLSchema, {}, { isSchema: true });
this._generatedSchema = build.newWithHooks(GraphQLSchema, {}, {
__origin: `GraphQL built-in`,
isSchema: true
});
}

@@ -196,0 +207,0 @@ if (!this._generatedSchema) {

{
"name": "graphile-build",
"version": "4.0.0-rc.9",
"version": "4.0.0-rc.10",
"description": "Build a GraphQL schema from plugins",

@@ -5,0 +5,0 @@ "main": "node8plus/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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