UNPKG

graphile-build

Version:

Build a GraphQL schema from plugins

170 lines (169 loc) 4.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "AddQueriesToSubscriptionsPlugin", { enumerable: true, get: function () { return _plugins.AddQueriesToSubscriptionsPlugin; } }); Object.defineProperty(exports, "ClientMutationIdDescriptionPlugin", { enumerable: true, get: function () { return _plugins.ClientMutationIdDescriptionPlugin; } }); Object.defineProperty(exports, "LiveCoordinator", { enumerable: true, get: function () { return _Live.LiveCoordinator; } }); Object.defineProperty(exports, "LiveMonitor", { enumerable: true, get: function () { return _Live.LiveMonitor; } }); Object.defineProperty(exports, "LiveProvider", { enumerable: true, get: function () { return _Live.LiveProvider; } }); Object.defineProperty(exports, "LiveSource", { enumerable: true, get: function () { return _Live.LiveSource; } }); Object.defineProperty(exports, "MutationPayloadQueryPlugin", { enumerable: true, get: function () { return _plugins.MutationPayloadQueryPlugin; } }); Object.defineProperty(exports, "MutationPlugin", { enumerable: true, get: function () { return _plugins.MutationPlugin; } }); Object.defineProperty(exports, "NodePlugin", { enumerable: true, get: function () { return _plugins.NodePlugin; } }); Object.defineProperty(exports, "QueryPlugin", { enumerable: true, get: function () { return _plugins.QueryPlugin; } }); Object.defineProperty(exports, "StandardTypesPlugin", { enumerable: true, get: function () { return _plugins.StandardTypesPlugin; } }); Object.defineProperty(exports, "SubscriptionPlugin", { enumerable: true, get: function () { return _plugins.SubscriptionPlugin; } }); Object.defineProperty(exports, "SwallowErrorsPlugin", { enumerable: true, get: function () { return _plugins.SwallowErrorsPlugin; } }); exports.buildSchema = void 0; Object.defineProperty(exports, "camelCase", { enumerable: true, get: function () { return _utils.camelCase; } }); Object.defineProperty(exports, "constantCase", { enumerable: true, get: function () { return _utils.constantCase; } }); Object.defineProperty(exports, "constantCaseAll", { enumerable: true, get: function () { return _utils.constantCaseAll; } }); exports.defaultPlugins = void 0; Object.defineProperty(exports, "formatInsideUnderscores", { enumerable: true, get: function () { return _utils.formatInsideUnderscores; } }); exports.getBuilder = void 0; Object.defineProperty(exports, "pluralize", { enumerable: true, get: function () { return _utils.pluralize; } }); Object.defineProperty(exports, "resolveNode", { enumerable: true, get: function () { return _resolveNode.default; } }); Object.defineProperty(exports, "singularize", { enumerable: true, get: function () { return _utils.singularize; } }); Object.defineProperty(exports, "upperCamelCase", { enumerable: true, get: function () { return _utils.upperCamelCase; } }); Object.defineProperty(exports, "upperFirst", { enumerable: true, get: function () { return _utils.upperFirst; } }); var _util = _interopRequireDefault(require("util")); var _SchemaBuilder = _interopRequireDefault(require("./SchemaBuilder")); var _plugins = require("./plugins"); var _resolveNode = _interopRequireDefault(require("./resolveNode")); var _utils = require("./utils"); var _Live = require("./Live"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const getBuilder = async (plugins, options = {}) => { const builder = new _SchemaBuilder.default(options); for (let i = 0, l = plugins.length; i < l; i++) { const plugin = plugins[i]; if (typeof plugin !== "function") { throw new Error(`Expected a list of plugin functions, instead list contained a non-function at index ${i}: ${_util.default.inspect(plugin)}`); } // $FlowFixMe: displayName builder._setPluginName(plugin.displayName || plugin.name); await plugin(builder, options); builder._setPluginName(null); } return builder; }; exports.getBuilder = getBuilder; const buildSchema = async (plugins, options = {}) => { const builder = await getBuilder(plugins, options); return builder.buildSchema(); }; exports.buildSchema = buildSchema; const defaultPlugins = [_plugins.SwallowErrorsPlugin, _plugins.StandardTypesPlugin, _plugins.NodePlugin, _plugins.QueryPlugin, _plugins.MutationPlugin, _plugins.SubscriptionPlugin, _plugins.ClientMutationIdDescriptionPlugin, _plugins.MutationPayloadQueryPlugin, _plugins.AddQueriesToSubscriptionsPlugin, _plugins.TrimEmptyDescriptionsPlugin]; exports.defaultPlugins = defaultPlugins; //# sourceMappingURL=index.js.map