Skip to content

QueryContext works on "node" resolver but not on "nodes" #8111

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

Closed
Tommsy64 opened this issue Mar 11, 2025 · 0 comments · Fixed by #8122
Closed

QueryContext works on "node" resolver but not on "nodes" #8111

Tommsy64 opened this issue Mar 11, 2025 · 0 comments · Fixed by #8122
Assignees
Milestone

Comments

@Tommsy64
Copy link

Tommsy64 commented Mar 11, 2025

Product

Hot Chocolate

Version

15.1.0-p.11

Link to minimal reproduction

https://github.com/Tommsy64/HotChocolate-IssueReproductions/blob/main/Program.cs

Steps to reproduce

  1. Create a Node type
  2. Create a NodeResolver for that type that has a QueryContext parameter.
  3. Attempt to resolve the node with nodes(ids: [ID!]!).

What is expected?

The nodes resolver works with QueryContext just like the node resolver.

What is actually happening?

A System.InvalidOperationException is thrown with the message "No coercion operator is defined between types 'NodeResolverBugReproduction.Types.Book' and 'NodeResolverBugReproduction.Types.Author'."

Relevant log output

Additional context

There appears to be a copy-paste typo in HotChocolateExecutionSelectionExtensions causing the GetOrCreateNodeExpression branch to only be called for the Node resolver and not the Nodes resolver. (Introduced by this commit.)

The if statement should be

if ((flags & FieldFlags.GlobalIdNodeField) == FieldFlags.GlobalIdNodeField
    || (flags & FieldFlags.GlobalIdNodesField) == FieldFlags.GlobalIdNodesField)
{
    return GetOrCreateNodeExpression<TValue>(selection);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants