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

Linked Resources and "self" link

Open
#69 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Let's say we have a Resource (A) that includes a reference to another Resource (B)(OneToOne).
The B resource belongs to a collection (C).
The use case is to display Resource A and a drop-down list that will display the name of the Resource B and other C Resources to pick from.

This currently will require 3 separate requests:

  1. Get Resource A from URL /A (this will include link to B like this /A/B)
  2. Get Resources C from URL /C (this will include B with link to self as /B)
  3. Get Resource B from /A/B (this will include link to self as /B) so we can find it in the collection

If this has to be done for many linked resources oh a large collection, it results in significant increase in traffic and degrades the performance.

Is there any way to include the actual link to B when returning A with links?

This:
{
links: {[{"rel":"B", "href":"/B" }]},
content: {...}
}

instead of current:
{
links: {[{"rel":"B", "href":"/A/B" }]},
content: {...}
}

Thanks.

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.

Research direction

No file, test, or entry point is named. Start by reproducing the Resource A, B, and C relationship described in the issue and trace Spring Data REST link generation; done means linked resources can expose B's direct self link without requiring the extra request, with existing link behavior covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.