holidayextras / jsonapi-client

Easily consume a json:api service in Javascript.
MIT License
68 stars 19 forks source link

Correctly deduplicate related resources #28

Closed theninj4 closed 8 years ago

theninj4 commented 8 years ago

The _relationHasResource is invoked on a resource when we want to add another resource to a relation. It needs to say "return true if this resources list of related resources already includes this new resource", thus de-duplicating related resources.

If we make a new resource A and add a related resource of B it'll look something like this:

A => [ B ]

If we then try and add B again, we need to de-duplicate it as-per the JSON:API spec.

pmcnr-hx commented 8 years ago

:+1: this should do the trick while still avoiding the lodash dependency.