Skip to content

Add support for embedded resources in ra-data-simple-rest#10898

Merged
djhi merged 3 commits intonextfrom
simple-rest-embed
Aug 27, 2025
Merged

Add support for embedded resources in ra-data-simple-rest#10898
djhi merged 3 commits intonextfrom
simple-rest-embed

Conversation

@fzaninotto
Copy link
Copy Markdown
Member

@fzaninotto fzaninotto commented Aug 26, 2025

Problem

The embed query meta is a way to tell API backends to embed related resources.

We use it in demos with a FakeRest backend. FakeRest does support embed. However, some of our demos use ra-data-simple-rest, and a fetch mock library (e.g., msw) to hook the simple REST API calls to FakeRest.

Since ra-data-simple-rest doesn't support embed, the embed parameter never reaches FakeRest in this setup, and so the embedded resources are never returned.

Solution

Pass the embed query meta as query param when specified.

dataProvider.getList('posts', {
    filter: {},
    pagination: { page: 1, perPage: 10 },
    sort: { field: 'title', order: 'DESC' },
    meta: { embed: ['author'] },
})
// http://localhost:3000/posts?embed=%5B%22author%22%5D&filter=%7B%7D&range=%5B0%2C9%5D&sort=%5B%22title%22%2C%22DESC%22%5D

@djhi djhi added this to the 5.11.0 milestone Aug 27, 2025
@djhi djhi merged commit 6540e3b into next Aug 27, 2025
15 checks passed
@djhi djhi deleted the simple-rest-embed branch August 27, 2025 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RFR Ready For Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants