Eager Loading
with
parameter. For example, when fetching a user (either via an index or a show request), you can include related data, such as the user's company
, by passing company
to the with
parameter. This ensures the user's company is loaded alongside the user resource, eliminating the need for additional API calls to retrieve that relationship.Example
1.
GET /api/user/1
).GET /api/company/42
).2.
GET /api/user/1?with=company
Multiple Relations
with
query parameter accepts arrays and comma-separated keys. The two formats look like this:
company.subscription
. This will result in the subscription being loaded inside the company.Modified at 2025-01-26 13:29:59