question: how would i annotate a relation that i only want to lookup if included
See original GitHub issueFor, example, let’s say events have associated users. So, we have
@JsonApiResource(type='events')
public class EventResource {
@JsonApiRelation(serialize = SerializeType.ONLY_ID)
UserResource user
}
So, I want to be be able to say
/events/1
to do a query against the events service, which gives us back events with a userId, so then the resulting json has relationships with
{ "data": { "id": "1", "type": "users" } }
I also want to be able to say
/events/1?include=user
to do a query against the events service AND a query against the user service, so now i have a full user object to include, so a "included": [ { "id": "1", "type": "users", "attributes": {...} } ]
Even if there was a LoopIncludeBehavior
of Always call a relationship's findManyTargets or findOneTarget if the field is included
, that wouldn’t be quite right, because I actually want to utilize the userId that I already have off of the event object, almost like a /users/1
call, rather than do a query against the user service using the event id.
Any thoughts on how the framework wants me to go about doing this?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:21 (17 by maintainers)
I was thinking of something like this:
maybe to clarify for non-insiders, it could then look like:
The user attribute would then still be managed & looked-up by crnk automatically. There would be no need to speciy relationship repositories for such cases.