Skip to content

Commit

Permalink
Fix race condition between Inject and Injectable (#1589)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkisiela committed Mar 2, 2021
1 parent 18fbe28 commit 2a68e78
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions packages/graphql-modules/src/di/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,19 @@ export function Injectable(options?: ProviderOptions): ClassDecorator {
const existingMeta = readInjectableMetadata(target as any);

const meta: InjectableMetadata = {
params: params.map((param, i) => {
const existingParam = existingMeta?.params?.[i];
return {
type: existingParam?.type || param,
optional:
typeof existingParam?.optional === 'boolean'
? existingParam.optional
: false,
};
}),
params:
existingMeta?.params?.length > 0 && params.length === 0
? existingMeta?.params
: params.map((param, i) => {
const existingParam = existingMeta?.params?.[i];
return {
type: existingParam?.type || param,
optional:
typeof existingParam?.optional === 'boolean'
? existingParam.optional
: false,
};
}),
options: {
...(existingMeta?.options || {}),
...(options || {}),
Expand Down

0 comments on commit 2a68e78

Please sign in to comment.