Skip to content

Commit b408fa9

Browse files
committed
Add brief docs section for the new option.
1 parent 6a63865 commit b408fa9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

docs/tutorial/fastapi/relationships.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ So we start again, and in the end, the server would just crash trying to get all
158158

159159
So, we need to carefully choose in which cases we want to include data and in which not.
160160

161+
### Specifically include a relation
162+
163+
If recursion is not an issue for a specific relations it might be handy not to
164+
duplicate the models for reading.
165+
166+
This can be done by adding `sa_relationship_kwargs={"lazy": "selectin"})` to
167+
your relationship (be careful with that option, this will not lazy load anymore 😱).
168+
Then add the config option `include_relations = {"field_to_include"}` for the
169+
field you want to **always** include.
170+
161171
## What Data to Include
162172

163173
This is a decision that will depend on **each application**.

0 commit comments

Comments
 (0)