forked from MichalLytek/type-graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added basic implementation for MichalLytek#124
- Loading branch information
Wessel van der Veen
committed
Oct 6, 2018
1 parent
5c00d31
commit 85b3f47
Showing
8 changed files
with
168 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { getMetadataStorage } from "../metadata/getMetadataStorage"; | ||
import { MethodAndPropDecorator } from "./types"; | ||
|
||
export interface Metadata { | ||
[index: string]: any; | ||
} | ||
|
||
export function Metadata(data: Metadata): ClassDecorator | MethodAndPropDecorator | any { | ||
return ( | ||
targetOrPrototype: Function | Object, | ||
propertyKey?: string | symbol, | ||
descriptor?: any, | ||
): void => { | ||
if (typeof targetOrPrototype === "function") { | ||
getMetadataStorage().collectAdditionalObjectTypeMetadata({ | ||
target: targetOrPrototype, | ||
data, | ||
}); | ||
} else if (propertyKey !== undefined) { | ||
getMetadataStorage().collectAdditionalFieldMetadata({ | ||
name: propertyKey, | ||
target: targetOrPrototype.constructor, | ||
data, | ||
}); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface Metadata { | ||
data: any; | ||
target: Function; | ||
name?: string | symbol; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.