|
I have models with deep relationships, say A -> B -> C -> D. In my transformers, I have this: In my controller, I return My problem is that it only gives me one level of relations deep. The type information is also consistent with this. The documentation says:
From that, I thought that I should only use Have I got that wrong? How should I use depth exactly? |
Replies: 2 comments 1 reply
|
Based on the docs, your top-level usage ( The likely gap isn't the transformer depth setting itself, it's what's actually in memory for it to serialize. A.query().preload('b', (q) => q.preload('c'))that only reaches two hops deep (A to B to C), so A.query().preload('b', (q) => q.preload('c', (q2) => q2.preload('d')))Worth checking that first: log |
|
Your original reading matches the docs, but the current implementation does not propagate that top-level depth. |
Your original reading matches the docs, but the current implementation does not propagate that top-level depth.
BaseSerializercalls the root resource withmaxDepth = -1(source), andItem.resolveconverts that override toundefined(source); the first nested transformer therefore falls back to its own default depth of 1. That explains both the one-level output and why putting.depth(4)on the nestedClinic.Transformer.transform(...)fixes it, so that is the practical workaround until the docs or implementation are corrected.