Skip to content

Include related models in "GET /mymodels" results #1889

Description

@GuillaumeJasmin

Description

Hi,
I start a big migration since Loopback 4 is now the current release.
However, there is many things not documented.

I try to use include filter, but it seems doesn't work. I'm not able to use it on my current project. I followed examples on the docs.

I first thought that my configuration was bad, so I tried it on loopback4-example-todo-list, but it doesn't work on the example too.

Current Behavior

When I try this request:

http://localhost:3000/todo-lists?filter={"include": [{"relation": "todos"}]}

or this

http://localhost:3000/todo-lists?filter[include]=todos

I get this 500 error:

500 Error: Relation "todos" is not defined for TodoList model

Expected Behavior

Should works like Loopback 3

How I can work with relation and the include filter on Loopback 4 ?

Thanks :)

Acceptance Criteria

  • All relations are supported (HasMany, BelongsTo, HasOne, etc.)
  • When passing the parameter name, quotes are not required to wrap around the param name. i.e.
    It should be:
http://localhost:3000/todo-lists?filter={"include": [{"relation": "todos"}]}

not:

http://localhost:3000/todo-lists?"filter"={"include": [{"relation": "todos"}]}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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