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

Polymorphic interfaces break prefetch when a nested field has filters applied #593

Open
pfcodes opened this issue Jul 21, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@pfcodes
Copy link

pfcodes commented Jul 21, 2024

Describe the Bug

Polymorphic interfaces break the prefetch cache when a nested field has filters/ordering applied.

This works:

{
  allIndividualCreatives { # Not polymorphic
    edges {
      node {
        id
        creativeWorkPortfolioProjects(order: { profileOrder: ASC}) { # ✅  Filter works without breaking prefetching
          edges {
            node {
              id
            }
          }
        }
      }
    }
  }
}

This also works:

{
  jobPosting(id: "Q3JlYXRpdmVKb2JQb3N0aW5nOjMyNQ==") {
    applications {
      edges {
        node {
          id
          creative { # Polymorphic
            creativeWorkPortfolioProjects { # ✅ Nested three levels deep, but prefetch doesn't break
              edges {
                node {
                  id
                }
              }
            }
          }
        }
      }
    }
  }
}

This doesn't:

{
  jobPosting(id: "Q3JlYXRpdmVKb2JQb3N0aW5nOjMyNQ==") {
    applications {
      edges {
        node {
          id
          creative { # Polymorphic
            creativeWorkPortfolioProjects(order: { profileOrder: ASC}) { # ❌ Nested 3 levels deep and prefetch breaks because of the filter
              edges {
                node {
                  id
                }
              }
            }
          }
        }
      }
    }
  }
}

System Information

  • Strawberry version: strawberry-graphql==0.236.0
  • Strawberry django version: strawberry-graphql-django==0.47.0

Additional Context

Apparently the prefetched cache is being sent to the subclass, but the filters are being applied to the parent class. I know this because I see error messages about an n+1 query on the parent class only when applying the filters.

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant