inertia-laravel
inertia-laravel copied to clipboard
[v2] Partial reload incorrectly evaluates props not included in response (optional & lazy)
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.
"shared_list" => fn() => ...
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);
below resolveExcept
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