mercredi 14 novembre 2018

Querying composed resources

I'm currently trying to design a small REST API.

Let's say I have a resource (book) that is composed of multiple other resources (eg. author).

Both resources have separate API's that are deployed in different services (with their own databases).

The author doesn't know a thing about books. However books know their author.

Now I want to support queries like books?author.surname=Poe.

I'm struggling how an implementation could look like that supports this kind of filtering of linked resources.

Since the author doesn't know about books, I can't ask the author api to give me the matching authors and go from here to the related books. What I could do is ask for every book I have in the DB the author API for that books author and then filter that based on the authors name. But that sounds horribly unperformant.

I guess that nearly every SOA runs into this problem quite early in the design.

I'm asking if there is already a common pattern or best practice that solves this problem?

Aucun commentaire:

Enregistrer un commentaire