Combining decorators #1850
-
Is there any way to combine (or otherwise define/extend/alias) decorators, so that a combination of decorators can be repeatedly applied? My use case is that I have a lot of ID fields which are hex, and exactly 64 characters long, in various models.
I'm looking for a way to reduce the repetition here, and ideally apply a single decorator to each instance (or extend some base model but change the field name, or...). I can use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can use a custom scalar that then will be referenced. Like this:
But be aware that it will be referenced in the openAPI output. Like this:
As @key is set on a ModelProperty and not on a Scalar you still need to set it on every model-property. But I think just as defining a custom type in another language this is by design (as having custom data-types that set something on the object-level would be weird I think.) You could also think about using the spread operator or inheritance (if you don't mind the id-name being not adjustable).
|
Beta Was this translation helpful? Give feedback.
You can use a custom scalar that then will be referenced. Like this:
But be aware that it will be referenced in the openAPI output. Like this: