How to use the @graphql-codegen/plugin-helpers.normalizeConfig function in @graphql-codegen/plugin-helpers

To help you get started, we’ve selected a few @graphql-codegen/plugin-helpers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dotansimha / graphql-code-generator / packages / graphql-codegen-cli / src / codegen.ts View on Github external
task: wrapTask(async () => {
                      debugLog(`[CLI] Generating output`);
                      const normalizedPluginsArray = normalizeConfig(outputConfig.plugins);
                      const pluginLoader = config.pluginLoader || defaultLoader;
                      const pluginPackages = await Promise.all(normalizedPluginsArray.map(plugin => getPluginByName(Object.keys(plugin)[0], pluginLoader)));
                      const pluginMap: { [name: string]: CodegenPlugin } = {};
                      const preset: Types.OutputPreset = hasPreset ? (typeof outputConfig.preset === 'string' ? await getPresetByName(outputConfig.preset, defaultLoader) : outputConfig.preset) : null;

                      pluginPackages.forEach((pluginPackage, i) => {
                        const plugin = normalizedPluginsArray[i];
                        const name = Object.keys(plugin)[0];

                        pluginMap[name] = pluginPackage;
                      });

                      const mergedConfig = {
                        ...rootConfig,
                        ...(typeof outputFileTemplateConfig === 'string' ? { value: outputFileTemplateConfig } : outputFileTemplateConfig),
                      };