Open Sangeetha-Murugesan opened 2 years ago
I guess something like this should work
public class QueryableStringInvariantEqualsHandler : QueryableStringOperationHandler
{
public QueryableStringInvariantEqualsHandler(InputParser inputParser) : base(inputParser){ }
private static readonly MethodInfo _toLower = typeof(string).GetMethods().Single(
x => x.Name == nameof(string.ToLower) && x.GetParameters().Length == 0);
protected override int Operation => DefaultFilterOperations.Equals;
public override Expression HandleOperation(QueryableFilterContext context, IFilterOperationField field, IValueNode value, object? parsedValue)
{
Expression property = context.GetInstance();
if ( parsedValue is null)
{
return Expression.Equal(property, Expression.Constant(null));
}
if ( parsedValue is string str)
{
return Expression.Equal(
Expression.Call(property, _toLower),
Expression.Constant(str.ToLower()));
}
throw new InvalidOperationException();
}
}
@PascalSenn , adding the null condition in QueryableStringInvariantEqualsHandler class also not works,getting the same error
PS: I am getting object reference error in this line await next.Invoke(context); in useField Middleware.
@Sangeetha-Murugesan can you push a reproduction into a simple example project?
@PascalSenn , Source code is available in Source Code - Custom Filtering
@PascalSenn any update on this issue?
@Sangeetha-Murugesan I do not know what should not work in your example project
can you provide an example query or something similar?
PFB. Sample query to simulate the issue. On query execution, you will get object reference error because in response,one of the field value for which I have applied filter is null. If the response doesnt have any null value,it works fine. you can refer the sample response data in source file.
{ getpartSaleOrderInquiry{ data{ items{ partDetails(where:{mrstatusArr:{eq:"Pend"}}){ items{ mrstatusArr } } saleOrderNo saleOrderStatus } } } }
@PascalSenn @tobias-tengler , any update on this?
Is there an existing issue for this?
Describe the bug
I was trying to implement case insensitive filtering and found this example on your documentation.
It is working fine if the resultant field has values. If the resultant field has value as null,it throws Object Reference error.
In my case, api return an array of data(shiptoCust) in which some might have value and some might be null. while applyig filter to this field,I am getting object reference not set to an instance.
Steps to reproduce
In Configure Method:
Relevant log output
No response
Additional Context?
No response
Product
Hot Chocolate
Version
12.6.1