Skip to content

Merge of nested relationships & includes on JsonApiCollection #11

@d8vjork

Description

@d8vjork

Replication example

Loading something twice as on a polymorphic relationship and somewhere else (included as of a nested relationship), imagine something like:

// PostController.php

public function index(JsonApiResponse $response)
{
    return $response->using(Post::with([
        'parent' => fn (MorphTo $morphTo) => $morphTo->morphWith([
            Group::class => [
                'createdBy', // this being user ID = 2
            ],
        ]),
        'author', // this being user ID = 2
        'author.avatars', // load avatars from post.author relationship thought groups will not have access to this!
    ]));
}

This will get into a race condition where author relationship (in this case could be of type user) will be different sometimes at the included data array because the user is actually the same in both relationships...

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions