blue-chip icon indicating copy to clipboard operation
blue-chip copied to clipboard

Includes only work if relationship name matches resource type

Open bewildergeist opened this issue 5 years ago • 2 comments

The .includes() feature only works if the resource name is the same as the resource type (optionally pluralized), e.g.:

relationships: {
  user: {data: {id: 8, type: "users"}}
}

But there is nothing in the spec AFAIK that requires that, so this is also valid:

relationships: {
  reviewer: {data: {id: 8, type: "users"}}
}

But blue-chip will not find that relationship. I haven't dug into the code yet to determine what this will require, but this ought to be supported, right?

bewildergeist avatar Jul 02 '19 08:07 bewildergeist

Thanks for opening. It should be working and there are some tests that show it working with virtual names. If you can create a failing test I can take a look.

Check out this test and the #plural and #singular methods on base class. https://github.com/blue-chip-js/blue-chip/blob/master/tests/CustomSingular.js

Also check out the virtual attr names from this test. https://github.com/blue-chip-js/blue-chip/blob/master/tests/NestedRelationships.js#L23 https://github.com/blue-chip-js/blue-chip/blob/master/testHelpers/fixtures/specsNormalized.js#L37

mfpiccolo avatar Jul 02 '19 16:07 mfpiccolo

Thanks for your quick reply on this, @mfpiccolo, and sorry for not getting back sooner. I'm still experiencing the issue, so will see if I can create a failing test.

bewildergeist avatar Aug 16 '19 12:08 bewildergeist