You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scenario
I'm wanting to extend my ASP.NET Web API capabilities to include GraphQL and ran into an issue while starting down this path. The services I've implemented heavily uses DDD (Domain-Driven Design) to the point where properties don't necessarily use native runtime types (string, int, long, etc.,). There are a couple reasons for this, but mainly to push some of domain logic into the types themselves.
Below is a struct that is used quite a bit and an example above it of it's use. Granted the business logic has been removed it demonstrates the use case.
Issue:
When implementing custom filtering I am able to use most of the binary operators, but when I try to do a contains I get the error below. Is there a way around this?
"extensions": {
"message": "Method 'Boolean Contains(System.String)' declared on type 'System.String' cannot be called with instance of type 'System.Nullable`1[MyPortal.Name]'",
"stackTrace": " at System.Linq.Expressions.Expression.ValidateCallInstanceType(Type instanceType, MethodInfo method)\r\n at System.Linq.Expressions.Expression.ValidateMethodAndGetParameters(Expression instance, MethodInfo method)\r\n at System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, Expression arg0)\r\n at System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, IEnumerable`1 arguments)\r\n at HotChocolate.Data.Filters.Expressions.FilterExpressionBuilder.Contains(Expression property, Object value)\r\n at HotChocolate.Data.Filters.Expressions.QueryableStringContainsHandler.HandleOperation(QueryableFilterContext context, IFilterOperationField field, IValueNode value, Object parsedValue)\r\n at HotChocolate.Data.Filters.Expressions.QueryableOperationHandlerBase.TryHandleOperation(QueryableFilterContext context, IFilterOperationField field, ObjectFieldNode node, Expression& result)\r\n at HotChocolate.Data.Filters.FilterOperationHandler`2.TryHandleEnter(TContext context, IFilterField field, ObjectFieldNode node, ISyntaxVisitorAction& action)\r\n at HotChocolate.Data.Filters.FilterVisitor`2.OnFieldEnter(TContext context, IFilterField field, ObjectFieldNode node)\r\n at HotChocolate.Data.Filters.FilterVisitorBase`2.Enter(ObjectFieldNode node, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxWalker`1.Enter(ISyntaxNode node, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor`1.Visit[TNode,TParent](TNode node, TParent parent, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor`1.VisitChildren(ObjectValueNode node, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor`1.VisitChildren(ISyntaxNode node, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor`1.Visit[TNode,TParent](TNode node, TParent parent, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor`1.VisitChildren(ObjectFieldNode node, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor`1.VisitChildren(ISyntaxNode node, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor`1.Visit[TNode,TParent](TNode node, TParent parent, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor`1.VisitChildren(ObjectValueNode node, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor`1.VisitChildren(ISyntaxNode node, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor`1.Visit[TNode,TParent](TNode node, TParent parent, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor`1.VisitChildren(ObjectFieldNode node, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor`1.VisitChildren(ISyntaxNode node, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor`1.Visit[TNode,TParent](TNode node, TParent parent, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor`1.VisitChildren(ObjectValueNode node, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor`1.VisitChildren(ISyntaxNode node, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor`1.Visit[TNode,TParent](TNode node, TParent parent, TContext context)\r\n at HotChocolate.Language.Visitors.SyntaxVisitor`1.Visit(ISyntaxNode node, TContext context)\r\n at HotChocolate.Data.Filters.Expressions.QueryableFilterProvider.<ConfigureField>g__VisitFilterArgumentExecutor|11_0(IValueNode valueNode, IFilterInputType filterInput, Boolean inMemory)\r\n at HotChocolate.Data.Filters.Expressions.QueryableFilterProvider.<>c__DisplayClass15_0`1.<CreateApplicator>b__0(IResolverContext context, Object input)\r\n at HotChocolate.Data.Filters.Expressions.QueryableFilterProvider.<>c__DisplayClass10_0`1.<<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.MiddlewareCompiler`1.ExpressionHelper.AwaitTaskHelper(Task task)\r\n at HotChocolate.Authorization.AuthorizeMiddleware.InvokeAsync(IMiddlewareContext context)\r\n at HotChocolate.Authorization.AuthorizeDirectiveType.<>c__DisplayClass3_0.<<CreateMiddleware>b__1>d.MoveNext()\r\n--- End of stack trace from previous location ---\r\n at HotChocolate.Execution.Processing.Tasks.ResolverTask.ExecuteResolverPipelineAsync(CancellationToken cancellationToken)\r\n at HotChocolate.Execution.Processing.Tasks.ResolverTask.TryExecuteAsync(CancellationToken cancellationToken)"
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Scenario
I'm wanting to extend my ASP.NET Web API capabilities to include GraphQL and ran into an issue while starting down this path. The services I've implemented heavily uses DDD (Domain-Driven Design) to the point where properties don't necessarily use native runtime types (
string
,int
,long
, etc.,). There are a couple reasons for this, but mainly to push some of domain logic into the types themselves.Below is a struct that is used quite a bit and an example above it of it's use. Granted the business logic has been removed it demonstrates the use case.
Issue:
When implementing custom filtering I am able to use most of the binary operators, but when I try to do a
contains
I get the error below. Is there a way around this?Beta Was this translation helpful? Give feedback.
All reactions