question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug?] GraphQL Does not Filter Related Collections

See original GitHub issue

Consider 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: huhwtf

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:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
kiler129commented, Feb 11, 2019

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.item instead of api_platform.graphql.normalizer.item

0reactions
tobyski-tdsultracommented, Feb 14, 2022

I 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’.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found