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

The new IsSelected API incorrectly returns false when current selection is a List type #7859

Open
dkokotov opened this issue Dec 20, 2024 · 0 comments
Assignees
Milestone

Comments

@dkokotov
Copy link

Product

Hot Chocolate

Version

14.3

Link to minimal reproduction

https://github.com/CNaught-Inc/hotchocolate-repro-isselected

Steps to reproduce

Run the example, and send the following query:

{
  books {
    id
    title
    author {
      name
    }
  }
}

What is expected?

The author field is included in the response, as the resolver is checking whether it was selected with the IsSelected attribute, which should be returning true since the field was in fact included.

What is actually happening?

The author field in the response is null.

Relevant log output

Additional context

It does work correctly for the case where a single book is retrieved, eg the following query

{
  book {
    id
    title
    author {
      name
    }
  }
}

correctly includes author in the response.

I believe the culprit is this line:
https://github.com/ChilliCream/graphql-platform/blob/main/src/HotChocolate/Core/src/Types/Extensions/ResolverContextExtensions.cs#L665

It checks for the selection type being a composite type, but in the case of the books query it is a List type (or more precisely NotNullType with inner type of List). so the line above causes the logic for IsSelected to immediately return false, even without checking the selection set.

I verified locally that if you just change that to allow for List types, then the rest of the checking logic will work.

@michaelstaib michaelstaib added this to the HC-14.4.0 milestone Dec 23, 2024
@michaelstaib michaelstaib self-assigned this Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants