Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Laravel] Collection relations are not working correctly #6791

Closed
amermchaudhary opened this issue Nov 12, 2024 · 1 comment
Closed

[Laravel] Collection relations are not working correctly #6791

amermchaudhary opened this issue Nov 12, 2024 · 1 comment

Comments

@amermchaudhary
Copy link
Contributor

amermchaudhary commented Nov 12, 2024

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
@toitzi
Copy link
Contributor

toitzi commented Nov 13, 2024

Yes relates to this issue (api-platform/api-platform#2795).

Fix is in progress:
#6792

Feel free to test the fix, by applying the patch manually to your codebase. Altough please not that this probably is not the final implementation.

toitzi added a commit to toitzi/core that referenced this issue Nov 14, 2024
fix loading relationships by only loading those related to the model

Closes: api-platform#6791
Signed-off-by: Tobias Oitzinger <[email protected]>
toitzi added a commit to toitzi/core that referenced this issue Nov 14, 2024
fix loading relationships by only loading those related to the model

Closes: api-platform#6791
Signed-off-by: Tobias Oitzinger <[email protected]>
toitzi added a commit to toitzi/core that referenced this issue Nov 14, 2024
fix loading relationships by only loading those related to the model

Closes: api-platform#6791
Signed-off-by: Tobias Oitzinger <[email protected]>
toitzi added a commit to toitzi/core that referenced this issue Nov 14, 2024
fix loading relationships by only loading those related to the model

Closes: api-platform#6791
Signed-off-by: Tobias Oitzinger <[email protected]>
toitzi added a commit to toitzi/core that referenced this issue Nov 14, 2024
fix loading relationships by only loading those related to the model

Closes: api-platform#6791
Signed-off-by: Tobias Oitzinger <[email protected]>
soyuka pushed a commit that referenced this issue Nov 15, 2024
@soyuka soyuka closed this as completed Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants