We’re migrating from forest-express-sequelize to @forestadmin/agent.
The new agent tries to load fields / smart fields for relationships that are not defined in the record details page.
While navigating on the list view nothing happens, but if I navigate to the record details view (clicking on a single record) the agent tries to load smart fields even if the linked relationship is not defined.
In the list view the getValues is not called at all in the smart fields of the undefined relationship’s collection, but in the details view it is called passing [ {} ] as value for the records parameter, which causes many problems.
e.g. In the list view everything works, in the details view the record without the boat defined returns the error.
This is the expected behavior - Even on null relation, we’ll try to compute the potential list of smart fields on an empty record.
This behavior was backported from v1 as some existing users are using it - but we may be lacking a bit of documentation on this one - I’ll file a ticket right away.
The general rule of thumbs regarding field computation is that dependencies will not always be provided - and this needs to be manually checked on your end.
A potential solution we use to deal with this is the following:
Obvious it can be a bit more complex than this, especially when dealing with an API where you would not be able to iterate over the records, but the general idea is the same.
To give a bit more context:
It works on the table view most likely because your referenceField is able to be computed on null value - And the associated record embed a projection asking only for this referenceField.
It doesn’t in the record details because no projection is sent - Thus the full record needs to be recovered just in case the referenceField is actually a computed one.