blue-chip
blue-chip copied to clipboard
Includes only work if relationship name matches resource type
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?
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
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.