Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions graphql/codegen/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { CLI, CLIOptions, getPackageJson, Inquirerer } from 'inquirerer';

import { findConfigFile, loadConfigFile } from '../core/config';
import { generate } from '../core/generate';
import type { GraphQLSDKConfigTarget } from '../types/config';
import { mergeConfig, type GraphQLSDKConfigTarget } from '../types/config';
import {
buildDbConfig,
buildGenerateOptions,
Expand Down Expand Up @@ -114,11 +114,9 @@ export const commands = async (
let hasError = false;
for (const name of names) {
console.log(`\n[${name}]`);
const targetConfig = { ...targets[name], ...cliOptions } as GraphQLSDKConfigTarget;
if (targets[name].db && targetConfig.db) {
targetConfig.db = { ...targets[name].db, ...targetConfig.db };
}
const result = await generate(targetConfig);
const result = await generate(
mergeConfig(targets[name], cliOptions as GraphQLSDKConfigTarget),
);
printResult(result);
if (!result.success) hasError = true;
}
Expand Down
8 changes: 2 additions & 6 deletions graphql/codegen/src/cli/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { inflektTree } from 'inflekt/transform-keys';
import type { Question } from 'inquirerer';

import type { GenerateResult } from '../core/generate';
import type { GraphQLSDKConfigTarget } from '../types/config';
import { mergeConfig, type GraphQLSDKConfigTarget } from '../types/config';

export const splitCommas = (
input: string | undefined,
Expand Down Expand Up @@ -262,9 +262,5 @@ export function buildGenerateOptions(
const camelized = camelizeArgv(answers);
const normalized = normalizeCodegenListOptions(camelized);
const withDb = buildDbConfig(normalized);
const merged = { ...fileConfig, ...withDb } as GraphQLSDKConfigTarget;
if (fileConfig.db && merged.db) {
merged.db = { ...fileConfig.db, ...merged.db };
}
return merged;
return mergeConfig(fileConfig, withDb as GraphQLSDKConfigTarget);
}