jsonapi - include external resource

108 Views Asked by At

I'm trying to do an inclusion between Resources that are handled by different services. Both services use Katharsis. Let's assume those resources are Book and Publisher. I want to be able to include a publisher when GETing a book resource.

I know I could have the Book service do an HTTP call to the Publisher service. The issue here is that I'd get a JSON representation of the Publisher. I'd have to deserialize it into a Publisher POJO and put in in the Book POJO. Then Katharsis would serialize the whole thing again w/ the included Publisher.

One problem is the Book service would need to have knowledge of the Publisher model and its relationships etc. I suppose I could extract the model from the publisher service into a java api, and include it into the book service. Not sure it's a good practice though.

Another problem relates to the efficiency. I'm deserializing only to serialize again.

Is there a better way? How do people handle this?

0

There are 0 best solutions below