spring-projects / spring-projects/spring-data-rest

Include 'embedded' objects via request URL [DATAREST-211]

Open
#596 3 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

status: feedback-provided type: enhancement
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Benjamin M opened DATAREST-211 and commented

We all know the problem:

@Entity
class A {
  @ManyToOne B b;
}

@Entity
class B {
  @OneToMany List<A> as;
  @OneToOne C c;
}

The URLs for A and B only expose Links to the embedded entities, which is clear. But because of the n+1 query problem it should be possible to eager fetch those entities somehow and deliver them to the client using ONE request.

The simplest solution I can imagine is to let the client decide which resources to fetch. Look at this URL:

http://.../as/ID?include=b

or maybe even:

http://.../as/ID?include=b,b.c

This would be an AWESOME feature!


Affects: 2.0 M1 (Codd)

1 votes, 4 watchers

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.