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
The controller hooks for modifying a relation should receive the relation value. We can use the LazyRelation value here, just like the authorizers.
The LazyRelation class actually caches its value internally for a to-many relation. We should add caching of the to-one relation as well. Then we should keep the instance on the request, so that the same instance is used for both the authorization and the controller hooks: meaning there would only be one database request if the relation is accessed in both the authorization code and the controller hook.
The text was updated successfully, but these errors were encountered:
Actually don't think I want to make any changes at this stage. The second hook (after the relationship is updated) has access to the models that replaced, added-to or removed-from the relation. The main issue with providing them to the before hook is that the records aren't materialized at that point.
I would need a really good use-case to make changes, as the whole point with the current set up is that the JSON:API identifiers are passed down to the repository, which takes care of resolving them and modifying the relationship. It feels like use-case would be solved by using the after hook.
As per this issue:
cloudcreativity/laravel-json-api#264
The controller hooks for modifying a relation should receive the relation value. We can use the
LazyRelation
value here, just like the authorizers.The
LazyRelation
class actually caches its value internally for a to-many relation. We should add caching of the to-one relation as well. Then we should keep the instance on the request, so that the same instance is used for both the authorization and the controller hooks: meaning there would only be one database request if the relation is accessed in both the authorization code and the controller hook.The text was updated successfully, but these errors were encountered: