-
Notifications
You must be signed in to change notification settings - Fork 65
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
Get datatype of properties #123
Comments
Hey @s888, could you describe in more details what you would like to achieve? If you are using TypedJSON with 'reflect-metadata' you could check its documentation do just that. Unfortunately enums are not supported natively because of how typescript represents enums (and when using reflect we just get Object prototype). However, if you are using const enums with string values providing String for the decorator should work, but specific values will not be validated. |
Thank you for the reply. I want to dynamically create Graphql mutations from the class properties. But for that I need the data type of the properties. Say for example, for nested object if the property is a class I will need the name of the class so that I can pass it in the mutation. One way is I can create decorators like function pType(target : any, key : string) { But I was wondering if typedJson has an inbuilt way to find the type of property. |
Ok, but do you want to use that to “serialize” an object or just save it somewhere else? If the former, ie. use it in a custom serializer then I was planning to implement that at some point so I could just do it now, but if the latter then I would say that this is not what TypedJSON should be used for. Internally we either use reflect metadata as in your example or expect it to be provided in the decorator. |
Hi,
I there a built-in way to get datatype of @jsonMember properties?
Or will I have to write custom decorators for that?
Also, does it support enum? I am asking so since I couldn't find any example for the same.
Thanks in advance
The text was updated successfully, but these errors were encountered: