You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
endpoint("/v1/users/{user_id}", ["GET"]).dependency("param_name").was(Query()) # 1endpoint("/v1/users/{user_id}", ["GET"]).dependency("param_name").was(Depends(get_param_dependency)) # 2@endpoint("/v1/users/{user_id}", ["GET"]).dependency("param_name").was# 3defapply_some_changes_to_dependency():
defany_name_here(anything_here: str=Query()):
# Do any actions with the dependency herereturnanything_herereturnDepends(any_name_here)
(accepts an instance of Header/Query/Cookie) Allows you to change the type (header/query/cookie) or config of any dependency. Body should not be supported!
(accepts an instance of Depends) Allows you to change some dependency entirely to another function. It's useful when you want to change dependency's logic without affecting your route. However, sometimes type hints of the dependency cause circular imports from the business logic which is why we have Path 3.
(accepts a callable that returns a callable) Is same as 2 except that it allows you to import things after the migration has been defined so it solves the problem of circular imports. It's needed extremely rarely.
It is really implicit and prone to errors. It doesn't really give us anything in terms of functionality over the solutions above so I decided that it was a bad idea to include it.
Changing logic for handling params or removing the param completely
At this point it makes a lot more sense to just replace the route function.
The text was updated successfully, but these errors were encountered:
It is probably going to make Cadwyn too complex. However, we do need significant improvements in terms of documenting + testing + fixing our current dependencies approach
See #11 for more details.
Replacing individual params (query, header, cookie)
You can use
APIRoute.dependency_overrides_provider
for 3. Not sure if you should though...Rejected solutions
It is really implicit and prone to errors. It doesn't really give us anything in terms of functionality over the solutions above so I decided that it was a bad idea to include it.
Changing logic for handling params or removing the param completely
At this point it makes a lot more sense to just replace the route function.
The text was updated successfully, but these errors were encountered: