simple-graphql
Version:
The simple way to generates GraphQL schemas and Sequelize models from your models definition.
33 lines • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = (schemas, plugins, config, buildOptions) => {
const result = {};
const schemaMap = {};
schemas.forEach((schema) => (schemaMap[schema.name] = schema));
const defaultOptions = buildOptions.defaultPlugin || {};
plugins.forEach((plugin) => {
for (const schema of schemas) {
let options = ((schema.options || {})
.plugin || {})[plugin.name];
if (options === undefined) {
options = defaultOptions[plugin.name];
}
if (options === undefined) {
if (typeof plugin.defaultOptions === 'function') {
options = plugin.defaultOptions(schema);
}
else {
options = plugin.defaultOptions;
}
}
if (options != null && options.enable && plugin.applyToSchema) {
plugin.applyToSchema(schema, options, schemaMap, config);
}
}
});
schemas.forEach((schema) => {
result[schema.name] = schema;
});
return result;
};
//# sourceMappingURL=applyPluginsToSchemas.js.map