From 4c6e563c28b460507070a6567f254f5e741706b2 Mon Sep 17 00:00:00 2001 From: Enda Phelan Date: Fri, 18 Sep 2020 12:52:53 +0100 Subject: [PATCH] fix: package name override --- packages/graphback/src/loadPlugins.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/graphback/src/loadPlugins.ts b/packages/graphback/src/loadPlugins.ts index 40ed9b0fa9..5d986ca922 100644 --- a/packages/graphback/src/loadPlugins.ts +++ b/packages/graphback/src/loadPlugins.ts @@ -1,27 +1,28 @@ /* eslint-disable @typescript-eslint/no-var-requires */ import { GraphbackPlugin } from "@graphback/core"; -export function loadPlugins(pluginConfig: any): GraphbackPlugin[] { - if (!pluginConfig) { +export function loadPlugins(pluginConfigMap: any): GraphbackPlugin[] { + if (!pluginConfigMap) { return []; } const pluginInstances = []; - for (const pluginLabel of Object.keys(pluginConfig)) { + for (const pluginLabel of Object.keys(pluginConfigMap)) { let pluginName = pluginLabel; if (pluginLabel.startsWith('graphback-')) { // Internal graphback plugins needs rename pluginName = pluginLabel.replace('graphback-', '@graphback/codegen-'); } - if(config.packageOverride){ - pluginName = config.packageOverride; + // override package name + if(pluginConfigMap[pluginLabel].packageNameOverride){ + pluginName = pluginConfigMap[pluginLabel].packageNameOverride; } try { // eslint-disable-next-line @typescript-eslint/no-require-imports const plugin = require(pluginName); if (plugin.Plugin) { - const config = pluginConfig[pluginLabel]; + const config = pluginConfigMap[pluginLabel]; pluginInstances.push(new plugin.Plugin(config)); } else {