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

Adding an excerpt projection to a repository confusingly forces its entities to be embedded in other responses [DATAREST-1350]

Open
#1,713 0 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

in: repository type: bug type: documentation
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

magneticflux- opened DATAREST-1350 and commented

This isn't mentioned explicitly in documentation anywhere that I found. In RepositoryRestResource::excerptProjection related resources are mentioned, but it isn't clear under what conditions related resources are inlined or where they will be inlined.

Expected behavior:
Creating a excerpt projection for a RestRepository for Entity A alters the response to that repository endpoint, but not responses from the repository for Entity B, where B contains links to A.

Actual behavior:
All references to Entity A inside Entity B are embedded, regardless if they embedded before creating an excerpt for A. This can cause an N^2 size explosion if there are many of Entity B that have many of Entity A related to them.

Thoughts:
It seems like there should be finer-grained control over what gets embedded and what gets linked. Perhaps an annotation for specifying what fields/collections are embedded or not instead of the logic inside EmbeddedResourcesAssembler?


Affects: 3.1.5 (Lovelace SR5)

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.