-
Notifications
You must be signed in to change notification settings - Fork 10
Included type seems broken #10
Copy link
Copy link
Open
Description
The setting:
I have two serializers: Product and ProductShopVideo.
// file JsonApiViews/V1/Product.js
class Product extends JsonApiView {
get attributes() {
return [
'title',
'sku',
// ... some more attrs here, doesn't really matter
'active'
];
}
productShopVideos() {
return this.hasMany('App/Http/JsonApiViews/V1/ProductShopVideo', {
included: true,
excludeRelation: 'product',
ref: '_id'
})
}
}// file JsonApiViews/V1/Product.js
class ProductShopVideo extends JsonApiView {
get attributes() {
return [
"addedDate" ,
"deletedBy" ,
"deleted" ,
"addedBy" ,
"disabled"
];
}
product() {
return this.belongsTo('App/Http/JsonApiViews/V1/Product', {
ref: 'product'
});
}
}The result I recieve using proper data and the Product serializer is:
{
"meta": {},
"included": [
{
"type": "productShopVideos",
"id": "5b432fd15c242f0458c15a9d",
"attributes": {}
}
],
"data": {
"type": "product",
"id": "5b432fd05c242f0458c15a9a__499",
"attributes": {},
"relationships": {
"product-shop-videos": {
"data": [
{
"type": "productShopVideos",
"id": "5b432fd15c242f0458c15a9d"
}
]
}
}
}
}
I removed attributes for both to make it a bit clear. As you can see, the type for ProductShopVideo in included is not relevant. It should be kebab-cased as well.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels