Flags enum support in Filtering
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
I am trying to use flags enum support #5186 (I am using also mongodb) but there is a problem with filters. Example:
[Flags]
public enum ExampleEnum { First, Second, Third }
and i have entity that have property of ExampleEnum with value : Second | Third ( value 3) With filter
{
data(skip: 0, take: 10, where: {
exampleEnum : { eq : { isSecond:true}}
}
it does not match document beacuse query mongo db is {{ "ExampleEnum " : { "$eq" : 1 } } } Should be how to write query in Banana Cake Pop? But this is the query that it allow to write.
Update 1
Now,I am forcing type in FilterInputType with
descriptor.Field("exampleEnum").Type(typeof(ExampleEnum ));
and now i can use syntax
where: {
exampleEnum : { isSecond:true}
}
but I have Unexcepcted ExecutionError:
System.Collections.Generic.Stack1.ThrowForEmptyStack()\r\n at System.Collections.Generic.Stack1.Pop()\r\n at HotChocolate.Data.MongoDb.Filters.MongoDbDefaultFieldHandler.TryHandleLeave(MongoDbFilterVisitorContext context, IFilterField field, ObjectFieldNode node, ISyntaxVisitorAction& action)\r\n at HotChocolate.Data.Filters.FilterVisitor2.OnFieldLeave(TContext context, IFilterField field, ObjectFieldNode node)\r\n at HotChocolate.Data.Filters.FilterVisitorBase2.Leave(ObjectFieldNode node, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor1.Visit[T,P](T node, P parent, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor1.VisitChildren(ObjectValueNode node, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor1.Visit[T,P](T node, P parent, TContext context)\r\n at HotChocolate.Data.MongoDb.Filters.MongoDbFilterProvider.<>c__DisplayClass5_01.<<CreateExecutor>g__ExecuteAsync|1>d.MoveNext()\r\n--- End of stack trace from previous location ---\r\n at HotChocolate.Data.MongoDb.Sorting.MongoDbSortProvider.<>c__DisplayClass5_01.<<CreateExecutor>g__ExecuteAsync|1>d.MoveNext()\r\n--- End of stack trace from previous location ---\r\n at HotChocolate.Types.Pagination.PagingMiddleware.InvokeAsync(IMiddlewareContext context)\r\n at HotChocolate.Utilities.MiddlewareCompiler1.ExpressionHelper.AwaitTaskHelper(Task task)\r\n at HotChocolate.Execution.Processing.Tasks.ResolverTask.ExecuteResolverPipelineAsync(CancellationToken cancellationToken)\r\n at HotChocolate.Execution.Processing.Tasks.ResolverTask.TryExecuteAsync(CancellationToken cancellationToken)"
Steps to reproduce
Use mongodb
Relevant log output
No response
Additional Context?
No response
Product
Hot Chocolate
Version
12.12.1
Hi @giocaputo
So that this fails when you bind the type directlry makes sense. We will have to check what the issue in filtering is.
Any updates on this?