]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
📝 Upate docs for advanced dependencies with `yield`, noting the changes in 0.121...
authorSebastián Ramírez <tiangolo@gmail.com>
Mon, 3 Nov 2025 13:19:58 +0000 (14:19 +0100)
committerGitHub <noreply@github.com>
Mon, 3 Nov 2025 13:19:58 +0000 (14:19 +0100)
docs/en/docs/advanced/advanced-dependencies.md

index e0404b389f9eee6fca988463e48de9e72511553d..5d6a40f46316c9d8919a76ac5f2a0e4cdf748e19 100644 (file)
@@ -70,12 +70,22 @@ If you understood all this, you already know how those utility tools for securit
 
 You most probably don't need these technical details.
 
-These details are useful mainly if you had a FastAPI application older than 0.118.0 and you are facing issues with dependencies with `yield`.
+These details are useful mainly if you had a FastAPI application older than 0.121.0 and you are facing issues with dependencies with `yield`.
 
 ///
 
 Dependencies with `yield` have evolved over time to account for the different use cases and to fix some issues, here's a summary of what has changed.
 
+### Dependencies with `yield` and `scope` { #dependencies-with-yield-and-scope }
+
+In version 0.121.0, FastAPI added support for `Depends(scope="function")` for dependencies with `yield`.
+
+Using `Depends(scope="function")`, the exit code after `yield` is executed right after the *path operation function* is finished, before the response is sent back to the client.
+
+And when using `Depends(scope="request")` (the default), the exit code after `yield` is executed after the response is sent.
+
+You can read more about it in the docs for [Dependencies with `yield` - Early exit and `scope`](../tutorial/dependencies/dependencies-with-yield.md#early-exit-and-scope).
+
 ### Dependencies with `yield` and `StreamingResponse`, Technical Details { #dependencies-with-yield-and-streamingresponse-technical-details }
 
 Before FastAPI 0.118.0, if you used a dependency with `yield`, it would run the exit code after the *path operation function* returned but right before sending the response.