Skip to content

Commit 470336a

Browse files
authoredJul 13, 2021
fix: make plugins optional for preset (#6305)
1 parent 6fa7e30 commit 470336a

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed
 

‎.changeset/loud-toys-draw.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@graphql-codegen/cli': patch
3+
'@graphql-codegen/plugin-helpers': patch
4+
---
5+
6+
don't require plugins for for config if preset provides plugin. Instead the preset should throw if no plugins were provided.

‎packages/graphql-codegen-cli/src/codegen.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ export async function executeCodegen(input: CodegenContext | Types.Config): Prom
124124
}
125125

126126
for (const filename of generateKeys) {
127-
generates[filename] = normalizeOutputParam(config.generates[filename]);
127+
const output = (generates[filename] = normalizeOutputParam(config.generates[filename]));
128128

129-
if (generates[filename].plugins.length === 0) {
129+
if (!output.preset && (!output.plugins || output.plugins.length === 0)) {
130130
throw new DetailedError(
131131
'Invalid Codegen Configuration!',
132132
`

‎packages/utils/plugins-helpers/src/helpers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function isOutputConfigArray(type: any): type is Types.OutputConfig[] {
2525
}
2626

2727
export function isConfiguredOutput(type: any): type is Types.ConfiguredOutput {
28-
return typeof type === 'object' && type.plugins;
28+
return (typeof type === 'object' && type.plugins) || type.preset;
2929
}
3030

3131
export function normalizeOutputParam(config: Types.OutputConfig | Types.ConfiguredOutput): Types.ConfiguredOutput {

0 commit comments

Comments
 (0)
Please sign in to comment.