[Bug?] GraphQL Does not Filter Related Collections
See original GitHub issueConsider a simple Location object containing collection of Links. The links are attached using M2M relationship (I also tested with O2M). When executing a query like the following:
location(id: "/api/location/some_uuid") {
links {
edges {
node {
id,
name
}
}
}
}
I get the following output in the profiler:

As you can see the topmost query (4) contains WHERE for the id of location, while 6 counts ALL links and 7 fetches ALL links (not just assigned to the Location).
I tried with and without repository defined on the Link entity - the behavior is the same. I’m currently running v2.4.0-beta.1.
Am I doing something wrong or this is a rather scary bug?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Filtering related docs via graphql - Help - Fauna Forums
I'd like to create a GraphQL query that can return a filtered view of related docs. ... type List @collection(name: "lists") { owner:...
Read more >GraphQL API style guide - GitLab Docs
GraphQL API style guide. This document outlines the style guide for the GitLab GraphQL API. How GitLab implements GraphQL. We use the GraphQL...
Read more >Filtering and sorting (Concepts) - Prisma
Use the Prisma Client API to filter records by any combination of fields or related record fields, and sort the results.
Read more >Postgres: Filter query results / search queries - Hasura
Filter query results and search queries on Postgres in Hasura. ... By design, the _eq or _neq operators will not return rows with...
Read more >Directus - Unable to query related (One to Many) collection
Related collections are not returned in GraphQL requests for one-to-many relationship. I have 2 collections blog and comment with the ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Ok, that was a PEBKAC. This came from the normalizers priority and the fact my custom normalizer was called before GraphQL one and the custom one was composing
api_platform.serializer.normalizer.iteminstead ofapi_platform.graphql.normalizer.itemI found this post through google and had exactly the same issue, my related collections were not auto filtered by the parent entity. To fix I just needed to ensure my custom Doctrine serializers included a format check to not run if $format == ‘graphql’.