Skip to content

[Laravel] Collection relations are not working correctly #6791

Closed
@amermchaudhary

Description

@amermchaudhary

API Platform version(s) affected: 4.*

Description
All collection relations return all records instead of related records

How to reproduce
Lets say I want to get a list of all my companies and the users related to those companies

  1. Create two related models (ex: company and user)
  2. Create a HasMany relation from first model to second model (company has many users)
  3. Try to query all companies with their users
query companies {
  companies {
    edges {
      node {
        id
        name
        users {
          edges {
            node{
              id
            }
          }
        }
      }
    }
  }
}
  1. The returned users will be from all companies instead of the related company

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions