when trying to facilitate expand function to a FastAPI endpoint using relationships get a "cyclic reference" error.
when the user defines expand=parents, we expand only the first layer, where all parents and children will have to count on how many relations they have on each. which works well
What I want to achieve is when parents.parents is defined, or any combination of these to expand the nested layers. expand can be any combination of XXX.YYY.XXX...
I have written a helper_function only to include data up until the level requested by user using SQL alchemy relationships
using pydantic 2.0.3 pydantic_core 2.3.0 fastapi 0.110.0
example pydantic Schema
from typing import Optional, List, Union
Person(BaseModel):
id: int
name: str
parents: Optional[Union[List['Person'], int]] = None
children: Optional[Union[List['Person'], int]] = None
Person's attributeparentsis of typelist, how can that attribute also have its ownparentsattribute? Can you please provide a reproducible example of code you want to execute, with a clear description of the output you wish to obtain, and what output you are obtaining instead?