Skip to content

Is it possible to include nested relationships? #44

Closed
@utf4

Description

@utf4

Is it possible to fetch nested relationship. lets say I am having three resource User, Roles, and Permissions. Permissions have reference of Roles and Roles have reference of Users. I want to Fetch a User along-with its all Permissions referenced against all of its Roles.

What I was trying to pass a query parameter http://myapi.com/v1/users?include=roles.permissions because in laravel nested relationships are fetched like this. This is giving me error of not allowed include.

I was looking if there is any work around, Otherwise what I have to do is:

  • Fetching User in first request.
  • Loop through all of its roles and send request to fetch their permissions one by one.

ps: I have considered users, roles, permissions example to make it simple. I am implementing this thing against some complex data models which do have hundreds of relationship records.

Thanks
Furqan Aziz

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