Skip to content

Resource inheritance: can't use relationships from derived types in pagination chain #1642

Open
@bkoelman

Description

@bkoelman

DESCRIPTION

Using the models described in #1639, the following request:

GET /manufacturers/1?include=vehicles.lights&page[size]=vehicles.lights:5

fails with the following error:

{
  "links": {
    "self": "/manufacturers/1?include=vehicles.lights&page[size]=vehicles.lights:5"
  },
  "errors": [
    {
      "id": "b5aa9a5d-3b54-4076-bf3a-599894fbd924",
      "status": "400",
      "title": "The specified pagination is invalid.",
      "detail": "Field 'lights' does not exist on resource type 'vehicles'. Failed at position 10: vehicles.^lights:5",
      "source": {
        "parameter": "page[size]"
      }
    }
  ],
  "included": []
}

This scenario has been overlooked when #1142 was implemented.

Once this is fixed, the test Can_get_primary_resource_with_derived_includes can be simplified to create fewer resources and specify a page size lower than the default (10) for the related resources.

EXPECTED BEHAVIOR

Relationship chains in pagination expressions can reference relationships in derived types. Should handle the ShoppingBasket case from #1142 similarly to how it works with includes, so it won't cause failure.

ACTUAL BEHAVIOR

Error 400.

VERSIONS USED

  • JsonApiDotNetCore version: latest master at 0c79d35
  • ASP.NET Core version: 8.0
  • Entity Framework Core version: 8.0
  • Database provider: N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions