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

Error when nested sorting using a new approach QueryContext #8059

Open
Veribelll opened this issue Feb 21, 2025 · 0 comments · May be fixed by #8061
Open

Error when nested sorting using a new approach QueryContext #8059

Veribelll opened this issue Feb 21, 2025 · 0 comments · May be fixed by #8061

Comments

@Veribelll
Copy link

Product

Hot Chocolate

Version

15.0.3

Link to minimal reproduction

https://github.com/Veribelll/hot-chocolate-error/tree/nested-sorting

Steps to reproduce

Create two entities

public class Author
{
    public string Name { get; set; }
}

public class Book
{
    public string Title { get; set; }
    public Author Author { get; set; }
}

Create query

[QueryType]
public static class Query
{
    [UsePaging]
    [UseFiltering]
    [UseSorting]
    public static Connection<Book> GetBooks(PagingArguments pagingArguments, QueryContext<Book> queryContext)
        => Connection.Empty<Book>();
}

Execute request

query {
  books(order: [ {
     author:  {
        name: ASC
     }
  }]) {
    nodes {
      title
    }
  }
}

What is expected?

Successful execution of the request

What is actually happening?

Error in SortingContext

Relevant log output

"stackTrace": "   at System.Collections.ThrowHelper.ThrowKeyNotFoundException[TKey](TKey key)\n   at System.Collections.Frozen.FrozenDictionary`2.get_Item(TKey key)\n   at HotChocolate.Types.FieldCollection`1.get_Item(String fieldName) in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Core\\src\\Types\\Types\\FieldCollection.cs:line 27\n   at HotChocolate.Data.Sorting.SortingContext.SortDefinitionFormatter.Leave(ObjectFieldNode node, Context context) in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Data\\src\\Data\\Sorting\\Context\\SortingContext.cs:line 190\n   at HotChocolate.Language.Visitors.SyntaxWalker`1.Leave(ISyntaxNode node, TContext context) in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Language\\src\\Language.Visitors\\SyntaxWalker~1.Leave.cs:line 46\n   at HotChocolate.Language.Visitors.SyntaxVisitor`1.Visit[TNode,TParent](TNode node, TParent parent, TContext context) in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Language\\src\\Language.Visitors\\SyntaxVisitor~1.cs:line 83\n   at HotChocolate.Language.Visitors.SyntaxVisitor`1.VisitChildren(ObjectValueNode node, TContext context) in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Language\\src\\Language.Visitors\\SyntaxVisitor~1.VisitationMap.cs:line 446\n   at HotChocolate.Language.Visitors.SyntaxVisitor`1.VisitChildren(ISyntaxNode node, TContext context) in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Language\\src\\Language.Visitors\\SyntaxVisitor~1.VisitationMap.cs:line 26\n   at HotChocolate.Language.Visitors.SyntaxVisitor`1.Visit[TNode,TParent](TNode node, TParent parent, TContext context) in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Language\\src\\Language.Visitors\\SyntaxVisitor~1.cs:line 74\n   at HotChocolate.Language.Visitors.SyntaxVisitor`1.VisitChildren(ListValueNode node, TContext context) in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Language\\src\\Language.Visitors\\SyntaxVisitor~1.VisitationMap.cs:line 431\n   at HotChocolate.Language.Visitors.SyntaxVisitor`1.VisitChildren(ISyntaxNode node, TContext context) in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Language\\src\\Language.Visitors\\SyntaxVisitor~1.VisitationMap.cs:line 24\n   at HotChocolate.Language.Visitors.SyntaxVisitor`1.Visit[TNode,TParent](TNode node, TParent parent, TContext context) in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Language\\src\\Language.Visitors\\SyntaxVisitor~1.cs:line 74\n   at HotChocolate.Language.Visitors.SyntaxVisitor`1.Visit(ISyntaxNode node, TContext context) in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Language\\src\\Language.Visitors\\SyntaxVisitor~1.cs:line 59\n   at HotChocolate.Data.Sorting.SortingContext.SortDefinitionFormatter.Rewrite[T](IValueNode node, IType type, Expression parameter) in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Data\\src\\Data\\Sorting\\Context\\SortingContext.cs:line 159\n   at HotChocolate.Data.Sorting.SortingContext.AsSortDefinition[T]() in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Data\\src\\Data\\Sorting\\Context\\SortingContext.cs:line 132\n   at HotChocolate.Data.Types.Products.ProductQueriesResolvers.ProductQueries_GetProductsAsync_Resolver(IResolverContext context) in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Data\\test\\Data.PostgreSQL.Tests\\obj\\Debug\\net9.0\\HotChocolate.Types.Analyzers\\HotChocolate.Types.Analyzers.GraphQLServerGenerator\\HotChocolateResolvers.735550c.g.cs:line 288\n   at HotChocolate.Types.Helpers.FieldMiddlewareCompiler.<>c__DisplayClass9_0.<<CreateResolverMiddleware>b__0>d.MoveNext() in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Core\\src\\Types\\Types\\Helpers\\FieldMiddlewareCompiler.cs:line 129\n--- End of stack trace from previous location ---\n   at HotChocolate.Types.UnwrapFieldMiddlewareHelper.<>c__DisplayClass0_1.<<CreateDataMiddleware>b__1>d.MoveNext() in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Data\\src\\Data\\Extensions\\UnwrapFieldMiddlewareHelper.cs:line 16\n--- End of stack trace from previous location ---\n   at HotChocolate.Types.UnwrapFieldMiddlewareHelper.<>c__DisplayClass0_1.<<CreateDataMiddleware>b__1>d.MoveNext() in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Data\\src\\Data\\Extensions\\UnwrapFieldMiddlewareHelper.cs:line 16\n--- End of stack trace from previous location ---\n   at HotChocolate.Types.Pagination.PagingMiddleware.InvokeAsync(IMiddlewareContext context) in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Core\\src\\Types\\Types\\Pagination\\PagingMiddleware.cs:line 20\n   at HotChocolate.Execution.Processing.Tasks.ResolverTask.ExecuteResolverPipelineAsync(CancellationToken cancellationToken) in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Core\\src\\Execution\\Processing\\Tasks\\ResolverTask.Execute.cs:line 139\n   at HotChocolate.Execution.Processing.Tasks.ResolverTask.TryExecuteAsync(CancellationToken cancellationToken) in E:\\Projects\\graphql-platform\\src\\HotChocolate\\Core\\src\\Execution\\Processing\\Tasks\\ResolverTask.Execute.cs:line 110"

Additional context

No response

Veribelll added a commit to Veribelll/hot-chocolate that referenced this issue Feb 21, 2025
@Veribelll Veribelll linked a pull request Feb 21, 2025 that will close this issue
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.

1 participant