-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
When using a virtual field with dependsOn referencing a relation, the relation data is not fetched unless the relation is also explicitly included in the display array.
Basic Example
// ❌ This doesn't work - employer data is not fetched
display: [
{
key: "employerName",
label: "Employer Name",
dependsOn: ["employer"],
formatter: ({ row }) => {
const emp = row?.employer;
return `${emp?.user?.firstName ?? ""} ${emp?.user?.lastName ?? ""}`.trim();
},
type: "scalar"
}
]
// ✅ This works - but requires showing the raw relation column
display: [
"employer", // Must include this for the virtual field to work
{
key: "employerName",
label: "Employer Name",
dependsOn: ["employer"],
formatter: ({ row }) => {
const emp = row?.employer;
return `${emp?.user?.firstName ?? ""} ${emp?.user?.lastName ?? ""}`.trim();
},
type: "scalar"
}
]
Expected behavior:
dependsOn: ["employer"]should trigger fetching theemployerrelation (and ideally its nested relations likeemployer.user), allowing virtual fields to replace relation columns entirely.
Current behavior:
dependsOnonly declares a dependency but doesn't affect the Prisma query. The relation must be separately included indisplay, which defeats the purpose of creating a custom virtual field to replace it.
Additional context:
- Supporting nested relation depth (e.g.,
dependsOn: ["employer.user"]) would also be valuable for formatting deeply nested data. - This is similar to, but not the same as, this max depth for actions issue: feat: add depth selection for actions #470
Drawbacks
No response
Unresolved questions
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request