Partial reload `only` option behavior with lazy, deferred, and shared props
0 reputation · 12 Jul 2020, 10:21 UTC
0 reputation · 12 Jul 2020, 10:21 UTC
Goal: determine whether the `only` filter applied during a partial reload also limits shared middleware data and whether lazy or deferred props are treated as already requested when omitted from `only`.
Constraints: the `only` option is scoped to a single request, does not persist across full navigations, and its interaction with lazy props (evaluated on demand) and deferred props (auto‑triggered partial reload after initial render) is not explicitly defined in the current documentation, making the behavior version‑sensitive between Inertia 1 and Inertia 2.
Questions: Does specifying `only` exclude shared middleware props from the response, or are they always included regardless of the filter? When a lazy prop is omitted from `only`, does the client retain its previous value or remain undefined? If a deferred prop is scheduled but not listed in `only`, does the automatic partial reload still occur, and how does that affect the prop’s availability on the page?
35275 reputation · 12 Jul 2020, 16:20 UTC
The only option filters which page props the server evaluates and returns for that single request, but it does not strip shared middleware data: shared props are resolved by middleware outside the page-prop closure and are merged into the response regardless of the filter. Lazy and deferred props that are omitted from only are simply not re-evaluated — the client keeps whatever value (or absence of value) it already had. Nothing is reset to undefined as a side effect of being left out of only.
Shared data (registered via HandleInertiaRequests::share() in Laravel, or the equivalent in other adapters) is merged into every Inertia response after page props are resolved. Because the merge happens outside the per-prop filtering step, shared keys survive an only partial reload. This is the likely explanation if you are seeing "extra" keys in a filtered payload — it is expected behavior, not a leak in the filter. The caveat is that the exact boundary between "filtered page props" and "always-merged shared props" has shifted between Inertia 1 and Inertia 2, so treat any absolute claim here as version-sensitive and verify against your installed release.
onlyA lazy prop (a closure wrapped with Inertia::lazy() or an optional closure in v2) is only evaluated when explicitly requested. If it is omitted from only:
So "omitted" means "unchanged," not "cleared."
Deferred props (Inertia 2's Inertia::defer()) work by the client issuing a follow-up partial reload for the deferred group immediately after the initial render. That automatic reload is driven by the deferred group definition, not by any only list you pass elsewhere. If you fire your own partial reload with only: ['somethingElse'], the deferred prop's scheduled reload still occurs independently; conversely, your filtered request will not include the deferred prop's value. The practical effect: a deferred prop becomes available on the page once its own automatic reload completes, and your unrelated only requests neither block it nor deliver it early.
Because the shared-prop interaction differs between major versions, confirm empirically rather than trusting documentation summaries:
X-Inertia header return JSON) and check whether shared keys and omitted lazy keys appear.only reload that excludes it — it should be byte-identical.only calls.If you are pinned to Inertia 1, double-check the shared-middleware behavior specifically — that is the point most likely to differ from the description above. If you share your adapter and version, the answer can be narrowed further.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.