Skip to content

Commit aa955f1

Browse files
authoredDec 17, 2020
fix: hooks can be functions and need to be normalized (#5278)
If a hook is a single function, it is filtered out here, but arrays for functions would be kept.
1 parent 9ebf187 commit aa955f1

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
 

‎.changeset/wild-paws-type.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-codegen/cli': patch
3+
---
4+
5+
fix hooks as single function

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

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ function normalizeHooks(
2828
...prev,
2929
[hookName]: [_hooks[hookName]] as string[],
3030
};
31+
} else if (typeof _hooks[hookName] === 'function') {
32+
return {
33+
...prev,
34+
[hookName]: [_hooks[hookName]],
35+
};
3136
} else if (Array.isArray(_hooks[hookName])) {
3237
return {
3338
...prev,

0 commit comments

Comments
 (0)
Please sign in to comment.