Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TypeScriptPluginParsedConfig interface in visitor.ts #9793

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tame-apes-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-codegen/typescript': patch
---

Change TypeScriptPluginParsedConfig to include all values from TypeScriptPluginConfig
24 changes: 15 additions & 9 deletions packages/plugins/typescript/typescript/src/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,21 @@ export interface TypeScriptPluginParsedConfig extends ParsedTypesConfig {
avoidOptionals: AvoidOptionalsConfig;
constEnums: boolean;
enumsAsTypes: boolean;
numericEnums: boolean;
futureProofEnums: boolean;
futureProofUnions: boolean;
enumsAsConst: boolean;
numericEnums: boolean;
onlyEnums: boolean;
onlyOperationTypes: boolean;
immutableTypes: boolean;
maybeValue: string;
inputMaybeValue: string;
noExport: boolean;
disableDescriptions: boolean;
useImplementingTypes: boolean;
wrapEntireFieldDefinitions: boolean;
entireFieldWrapperValue: string;
allowEnumStringTypes: boolean;
}

export const EXACT_SIGNATURE = `type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };`;
Expand All @@ -58,25 +62,27 @@ export class TsVisitor<
> extends BaseTypesVisitor<TRawConfig, TParsedConfig> {
constructor(schema: GraphQLSchema, pluginConfig: TRawConfig, additionalConfig: Partial<TParsedConfig> = {}) {
super(schema, pluginConfig, {
noExport: getConfigValue(pluginConfig.noExport, false),
avoidOptionals: normalizeAvoidOptionals(getConfigValue(pluginConfig.avoidOptionals, false)),
maybeValue: getConfigValue(pluginConfig.maybeValue, 'T | null'),
inputMaybeValue: getConfigValue(
pluginConfig.inputMaybeValue,
getConfigValue(pluginConfig.maybeValue, 'Maybe<T>')
),
constEnums: getConfigValue(pluginConfig.constEnums, false),
enumsAsTypes: getConfigValue(pluginConfig.enumsAsTypes, false),
numericEnums: getConfigValue(pluginConfig.numericEnums, false),
futureProofEnums: getConfigValue(pluginConfig.futureProofEnums, false),
futureProofUnions: getConfigValue(pluginConfig.futureProofUnions, false),
enumsAsConst: getConfigValue(pluginConfig.enumsAsConst, false),
numericEnums: getConfigValue(pluginConfig.numericEnums, false),
onlyEnums: getConfigValue(pluginConfig.onlyEnums, false),
onlyOperationTypes: getConfigValue(pluginConfig.onlyOperationTypes, false),
immutableTypes: getConfigValue(pluginConfig.immutableTypes, false),
maybeValue: getConfigValue(pluginConfig.maybeValue, 'T | null'),
inputMaybeValue: getConfigValue(
pluginConfig.inputMaybeValue,
getConfigValue(pluginConfig.maybeValue, 'Maybe<T>')
),
noExport: getConfigValue(pluginConfig.noExport, false),
disableDescriptions: getConfigValue(pluginConfig.disableDescriptions, false),
useImplementingTypes: getConfigValue(pluginConfig.useImplementingTypes, false),
entireFieldWrapperValue: getConfigValue(pluginConfig.entireFieldWrapperValue, 'T'),
wrapEntireDefinitions: getConfigValue(pluginConfig.wrapEntireFieldDefinitions, false),
entireFieldWrapperValue: getConfigValue(pluginConfig.entireFieldWrapperValue, 'T'),
allowEnumStringTypes: getConfigValue(pluginConfig.allowEnumStringTypes, false),
...additionalConfig,
} as TParsedConfig);

Expand Down