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

Bug: UseProjections prevents UseFilter from working in nested collections #7066

Open
JonnyIV opened this issue Apr 18, 2024 · 3 comments
Open
Labels
Area: Data Issue is related to filtering, sorting, pagination or projections 🐛 bug Something isn't working 🌶️ hot chocolate 🔍 investigate Indicates that an issue or pull request needs more information.

Comments

@JonnyIV
Copy link

JonnyIV commented Apr 18, 2024

Product

Hot Chocolate

Version

13.9.0

Link to minimal reproduction

https://github.com/JonnyIV/GraphQlPagingFilterIssue/blob/master/GraphQlPagingFilterIssue/Query.cs

Steps to reproduce

code:

public class Query
{
    [UseProjection]
    public IQueryable<Movie> GetMovie() => new Movie[] { new() { Name = "Star Wars" } }.AsQueryable();
}
public class Movie
{
    public string Name { get; set; } = "";

    [UseFiltering]
    public IQueryable<Character> GetCharacters() => new Character[] new() { Name = "Luke Skywalker" }, new() { Name = "Darth Vader" }, new() { Name = "Princess Leia" } }.AsQueryable();
}
public class Character
{
    public string Name { get; set; } = "";
}

query:

query {
  movie {
    name
    characters(where: { name: { startsWith: "Darth" } }) {
      name
    }
  }
}

What is expected?

{
  "data": {
    "movie": [
      {
        "name": "Star Wars",
        "characters": [
          {
            "name": "Darth Vader"
          }
        ]
      }
    ]
  }
}

What is actually happening?

{
  "data": {
    "movie": [
      {
        "name": "Star Wars",
        "characters": [
          {
            "name": "Luke Skywalker"
          },
          {
            "name": "Darth Vader"
          },
          {
            "name": "Princess Leia"
          }
        ]
      }
    ]
  }
}

Relevant log output

No response

Additional context

No response

@JonnyIV JonnyIV added the 🐛 bug Something isn't working label Apr 18, 2024
@JonnyIV JonnyIV changed the title Bug: Filter does not work on a paged collection if it is nested in a projected object Bug: Filter does not work if it is inside a projected object Apr 18, 2024
@JonnyIV JonnyIV changed the title Bug: Filter does not work if it is inside a projected object Bug: UseProjections prevents UseFilter from working in nested objects Apr 18, 2024
@JonnyIV JonnyIV changed the title Bug: UseProjections prevents UseFilter from working in nested objects Bug: UseProjections prevents UseFilter from working in nested collections Apr 18, 2024
@michaelstaib michaelstaib added 🌶️ hot chocolate 🔍 investigate Indicates that an issue or pull request needs more information. Area: Data Issue is related to filtering, sorting, pagination or projections labels Apr 22, 2024
@andhallberg
Copy link

I am facing the same issue.

@JonnyIV
Copy link
Author

JonnyIV commented May 2, 2024

The workaround I am using is disabling projections on the parent element. It is not optimal but suffices in my case until this is fixed.

@andhallberg
Copy link

Thanks @JonnyIV, I was trying the same thing. Unfortunately I have some properties on the object in the child collection that needs projection on the parent element to get their auto-generated resolvers (via EF Core) to work properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Data Issue is related to filtering, sorting, pagination or projections 🐛 bug Something isn't working 🌶️ hot chocolate 🔍 investigate Indicates that an issue or pull request needs more information.
Projects
None yet
Development

No branches or pull requests

3 participants