spring-projects / spring-projects/spring-data-rest
Add option to disable Projection for SDR repository [DATAREST-1189]
@odrotbohm is already working on this.
Since Dec 31, 2020.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Martin Myslík opened DATAREST-1189 and commented
I am trying to configure SDR Projections so they are applied only for certain situations. For example, I have two entities: Cycle and Record and each one of them has its own repository.
Cycle contains list of records and when I access "/cycles/{id}", I get HAL/JSON with a reference to the list of records ("/cycles/{id}/records").
I would like to have my records inlined in the response instead of having links so I created and ExcerptProjection which does that so I am able to access an endpoint like this: "cycles/{id}?projection=myProjection".
So far, everything works nicely. However, this has a very unpleasant side-effect. When accessing /cycles endpoint, I get an embedded list of cycles with this projection applied by default (all records are unfolded) which makes the response extremely verbose.
I know that the default behavior of projections is to be always applied for _embedded resources and it needs to be specified otherwise.
Is there a way to avoid having it applied by default and turn it off when needed?
If this is not possible (have not found out in documentation), would you consider this to be a new feature or suggest some workaround?
No further details from DATAREST-1189
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.