Closed xaun closed 5 years ago
The exact same problem occurs in version 2.0.0.-rc.10.
@pablorsk Do you want me to take a look?
Yeah, you're right. (https://jsonapi.org/format/#fetching-includes)
http://jsonapiplayground.reyesoft.com/ dont support yet compound includes, I can't test.
I made a PR for this issue to fix this. https://github.com/reyesoft/ngx-jsonapi/pull/140
PR #140 and PR #169 try to fix this problem. @maxi7587 take this issue on FE-4 (internal issue code of @reyesoft/reyesoft-team)
I'm on it!
@maxi7587 @pablorsk Has this been done? I can see #175 was merged, but I'm trying to test now on v2.0.2 and while it's not throwing errors, the nested include relationship resource has an empty id and empty attributes (in the network request, the relationships are included).
Something else I have noticed is that the while the DocumentCollection response of my all
request is_loaded
is true
, is_loaded
value for all nested relationships is false
.
In the screenshot below you can see the nested relationships which lead to the empty "fields" resource.
My services are registered and injected (no register warnings).
My models are defined correctly I believe
export class Product extends Resource {
public relationships = {
values: new DocumentCollection<ProductValue>()
}
}
export class ProductValue extends Resource {
public relationships = {
field: new DocumentResource<ProductValueField>()
}
}
export class ProductValueField extends Resource {
attributes: {
created_at: string
description: string
field_type: string
max_length: number | null
min_length: number | null
multiple: boolean
name: string
nid: string
position: number
required: boolean
section: string
updated_at: string
visible: boolean
}
}
@Injectable({
providedIn: 'root'
})
@Autoregister()
export class ProductService extends Service<Product> {
public resource = Product
public type = 'products'
constructor(
private productValueService: ProductValueService,
private productValueFieldService: ProductValueFieldService) {
super()
this.all({ include: ['values.field'] }).pipe(filter(res => !res.is_loaded)).subscribe(res => {
console.log(res) // this is the screenshotted output
})
}
}
@Injectable({
providedIn: 'root'
})
@Autoregister()
export class ProductValueService extends Service<ProductValue> {
public resource = ProductValue
public type = 'values'
constructor() {
super()
}
}
@Injectable({
providedIn: 'root'
})
@Autoregister()
export class ProductValueFieldService extends Service<ProductValueField> {
public resource = ProductValueField
public type = 'fields'
constructor() {
super()
}
}
Am I missing something? Thanks
@xaun please look what I did in #180, maybe it will help you.
Solved on v2.1.9
I'm having issues with this still in v2.1.10. Attributes in nest relationships are not always loaded:
Is the nested include supported?
On version 1.1.1 when trying to query with the above it breaks with stack trace:
The
resource_type_alias
is"comments.author"
, soresource.relationships[resource_type_alias].data
can never work.