Skip to content

Inertia::deepMerge and Laravel meta.links #2313

@guratr

Description

@guratr

In version v2.0.8 we now have deepMerge support, and it almost works, but there's one important issue that prevent's us from just using

'users' => Inertia::deepMerge(UserResource::collection(User::paginate()))

because in laravel it returns data with this structure

    data: [/* items */],
    meta: { 
        ...,
        links: [
         /* list of pagination links */
        ]
    },
    links: { /* pagination links */ }

and in packages/core/src/response.ts mergeProps functions is recursively called on objects, so after each request with deepMerge new items keep adding to meta.links array.
Maybe not everyone project uses meta.links to renter pagination links, but if you use it, then deepMerge becomes useless.
I was considering adding second argument to Inertia::deepMerge to specify list of keys to exclude from merging and transferring that array to js, but i'm not sure how flexible it would be with deeply nested keys.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions