Open MarcEspiard opened 1 month ago
I just came here to report the same issue.
Instead of not running the closure on partial realods, even if you use only: [key_not_included_here] or except: [key_included_here] it will correctly NOT appear in the response, but it will be evaluated and all the code inside the closure will run.
Hi,
Testing v2 beta1 released today.
Just testing deferred props and noticed that my shared props were evaluated during the loading of the deferred props (partial load), even though all my shared props are in the Optional form and shouldn't be evaluated during a partial load.
I've tracked the issue to the resolveProperties function in Response: https://github.com/inertiajs/inertia-laravel/blob/141256b2ed1833158852c9d239d00abec8ff4942/src/Response.php#L134-L159
Calling https://github.com/inertiajs/inertia-laravel/blob/141256b2ed1833158852c9d239d00abec8ff4942/src/Response.php#L144 resolves all props, no matter if they are supposed to be included in the response.
Moving
$props = $this->resolveArrayableProperties($props, $request);
belowresolveExcept
solves the issue as the props have been filtered at the point.I don't know the potential ramifications of moving this line of code since this is a brand new refactor, but if it's OK with you I'm happy to submit a PR for the fix. Just let me know