Open anyinfa opened 2 months ago
At the moment we don't support recursive queries so you would need to explicitly query for the levels in advance. Making a note of this!
At first I also thought I wanted recursive queries, but instead I've tackled this so far by letting my React app nest the UI layer components and each nested component using its own useQuery() only fetching 'Blocks' for their current level of the tree. Since my app allows the user to show/hide components in the tree, this actually helps address the issue of determining depth - I don't need to.
The tricky bit is having all those useQuery() hooks outstanding ... I'm not sure but I may be seeing way too many render() calls for no good reason.
However, I can also see cases where I'd want to grab a larger tree depth for some other purpose in a single UI component ... so this would be useful, yes.
Indeed, I have encountered such a need where I want to export all the data of a tree at once, which is unrelated to component rendering. In this case, it might be more appropriate to use a server-side approach to fetch the data or use useQuery
within the component.
You are correct. If the data is being fetched for rendering purposes, I would also control the depth of data retrieval using useQuery
, as it is sufficient for the current needs.
Assuming I have a Block with a one-to-many relationship field
children
that contains self-links. When I execute the querydb.useQuery({ blocks: { children: {} } });
, it only returns the first level ofchildren
. How can I make it return all levels ofchildren
together (up to a finite depth) without knowing the exact number of levels in advance? Thank you.