Skip to content

Attach action for MorphToMany Relations is broken #102

@captnCC

Description

@captnCC

In the dummy app the attach action for MorphToMany relations is broken and throws a LogicException: No schema for JSON:API resource type media.

Reproduction

I built a sample Laravel app from the included dummy:
https://github.com/byte-it/laravel-jsonapi-sample

A call POST api/v1/posts/{post}/relations/media then throws the mentioned error.

Cause

The LaravelJsonApi\Laravel\Routing\Route class tries to retrieve the Schema for the related model. Because the MorphToMany relation returns it "morph" name instead of resolving to a real schema name, the resolving fails.
Digging deeper it becomes apparent, that it start in the CollectionQuery that tries to resolve the rules for the filters etc.
I don't see the reason at this point why these are needed at this point because the POST request doesn't support any query parameters anyways.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions