-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
With the release 2.5 and the merge of #181 prefetch and embed should work.
Embedding does work 100% how react-admin expects it but prefetching not as far as I can see.
Without embedding and prefetching
<List ...>
...
<ReferenceField source="defectCategoryId" reference="defect-category" />
...
</List>
Leads to this API response:
[
{
id: 1,
defectCategoryId: 2,
...
},
...
]
With embedding
<List ... queryOptions={{meta: {embed: [defectCategoryId]}}}>
...
<TextField source="defect-category.title" />
...
</List>
And resolves to an api response like the following:
[
{
id: 1,
defectCategoryId: 2,
"defect-category": {
id: 2,
title: "test",
...
},
...
},
...
]
With prefetching
<List ... queryOptions={{meta: {prefetch: [defectCategoryId]}}}>
...
<ReferenceField source="defectCategoryId" reference="defect-category" />
...
</List>
And resolves to an api response like the following:
[
{
id: 1,
defectCategoryId: 2,
"defect-category": {
id: 2,
title: "test",
...
},
...
},
...
]
Which then leads to an error message logged (Sorry for the cryptic Next.js error but it is inside getPrefetchedData
):
TypeError: Cannot read properties of null (reading 'id')
at http://localhost:3001/_next/static/chunks/node_modules_4c61ac1e._.js:13805:54
at Array.some (<anonymous>)
at http://localhost:3001/_next/static/chunks/node_modules_4c61ac1e._.js:13804:42
at Array.forEach (<anonymous>)
at http://localhost:3001/_next/static/chunks/node_modules_4c61ac1e._.js:13803:28
at Array.forEach (<anonymous>)
at http://localhost:3001/_next/static/chunks/node_modules_4c61ac1e._.js:13796:19
at Array.forEach (<anonymous>)
at getPrefetchedData (http://localhost:3001/_next/static/chunks/node_modules_4c61ac1e._.js:13795:19)
at http://localhost:3001/_next/static/chunks/node_modules_4c61ac1e._.js:13493:34
Perhaps this is due to the different format react-admin expects the data like listed in the "meta.prefetched" response in the docs?
If I understand this correctly the embed works like it should.
The prefetch differs in the returned format.
I guess this is due to a limitation of PostgREST but I'm unsure here.
Metadata
Metadata
Assignees
Labels
No labels