inferencer: Custom key for `object` type property
How to set custom key that will represent an
object
type property? if it is not possible, is it a good idea if i manually swizzle @refinedev/inferencer/antd
from the github repository?12 Replies
Hey @killerudin! I'm the kapa.ai support bot. I've searched through the docs to try to answer your question. :wave:
----------------------
To set a custom key that will represent an
object
type property, you can use the fieldTransformer
prop in the Inferencer components. The fieldTransformer
is a function that takes the field as an argument and returns the modified field. You can customize the output of the Inferencer, such as setting a custom accessor
property for object
type fields or changing the type
of a field.
Here's an extract from the documentation about modifying inferred fields:
(Source: refine.dev/docs/packages/documentation/inferencer (https://refine.dev/docs/packages/documentation/inferencer))
As for manually swizzling @refinedev/inferencer/antd
from the GitHub repository, it's important to note that @refinedev/inferencer
is an experimental package and is in the early stages of development. It's not recommended to use it in production environments. If you have any suggestions or feedback, you can share them in the GitHub Discussions (https://github.com/refinedev/refine/discussions/3046).
----------------------<@478256651347165195> kapa.ai is still learning and improving, please let us how it did by reacting below
rising-crimsonOP•2y ago
is there any example for using
fieldTransformer
to set a custom key that will represent an object
type property?flat-fuchsia•2y ago
here is the example
Actually, inferencer designed to speed up development process. you can copy generated code and customize according to your needs.
Also, ofc you can use fieldTransformer to customize inferencer logic
rising-crimsonOP•2y ago
thank you very much for the reply, but i realized that my previous question is a bit misleading
rising-crimsonOP•2y ago
the actual problem that i'm facing is that the object needs to have one of the following properties:
https://refine.dev/docs/packages/documentation/inferencer/#:~:text=LIST%20OF%20KEYS%20THAT%20CAN%20BE%20USED%20TO%20REPRESENT%20AN%20object%20TYPE%20PROPERTY
Inferencer | refine
@refinedev/inferencer is a package that provides a way to automatically generate views for resources based on the data structure. The aim is to reduce the amount of time spent on creating views for resources by generating the code automatically that can be customized easily.
rising-crimsonOP•2y ago
but my data looks like this
rising-crimsonOP•2y ago
the closest thing is "provinceName", which is not listed as one of the keys that can be used
is there any way to add a custom key to this list?
flat-fuchsia•2y ago
when you use like this, u can get provinceName for antd table
flat-fuchsia•2y ago
i used this example data
rising-crimsonOP•2y ago
it works!
thank you very much 🙏
flat-fuchsia•2y ago
I'm glad to here that 🚀