Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add X-Inertia-Include-Data header #239

Closed
wants to merge 2 commits into from
Closed

Conversation

jaulz
Copy link

@jaulz jaulz commented Mar 23, 2021

This PR will support a new header called X-Inertia-Include-Data which allows users to explicitly request lazy data. If you think that this is a good idea we could not only check the header but also a specific key within the session (that was set with flash).

My specific use case is this:

  1. Page loads without lazy data
  2. User clicks on a button and lazy data is loaded (via reload)
  3. User submits form that triggers a controller method that redirects back
  4. Inertia replaces previously loaded lazy data with undefined because it's lazy and thus ignored in the new request

My idea would be to use the back method but flash some data:

back(303)->flash('Inertia-Include-Data', 'lazyDataKey');

and use a custom middleware:

$request->headers->set('X-Inertia-Include-Data', ($request->header('X-Inertia-Include-Data') ?? '') . ',' . (Session::get('Inertia-Include-Data') ?? ''), true);

Ideally, we could also create an Inertia helper that would do this magically:

Inertia::back()->include('lazyDataKey');

What do you think? Or is this use case considered somehow else?

@driesvints driesvints deleted the branch inertiajs:master May 15, 2024 15:01
@driesvints driesvints closed this May 15, 2024
@driesvints
Copy link
Collaborator

Heya. We removed our master branch. Feel free to re-attempt this to 1.x!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed 🚪
Development

Successfully merging this pull request may close these issues.

None yet

2 participants