public static Predicate Parse()

in src/Core/Models/GraphQLFilterParsers.cs [612:709]


    public static Predicate Parse(
        IMiddlewareContext ctx,
        IInputField argumentSchema,
        Column column,
        List<ObjectFieldNode> fields,
        Func<object, string?, string> processLiterals,
        bool isListType = false)
    {
        List<PredicateOperand> predicates = new();

        InputObjectType argumentObject = ExecutionHelper.InputObjectTypeFromIInputField(argumentSchema);
        foreach (ObjectFieldNode field in fields)
        {
            string name = field.Name.ToString();
            object? value = ExecutionHelper.ExtractValueFromIValueNode(
                value: field.Value,
                argumentSchema: argumentObject.Fields[field.Name.Value],
                variables: ctx.Variables);

            bool processLiteral = true;

            if (value is null)
            {
                continue;
            }

            PredicateOperation op;
            switch (name)
            {
                case "eq":
                    op = PredicateOperation.Equal;
                    break;
                case "neq":
                    op = PredicateOperation.NotEqual;
                    break;
                case "lt":
                    op = PredicateOperation.LessThan;
                    break;
                case "gt":
                    op = PredicateOperation.GreaterThan;
                    break;
                case "lte":
                    op = PredicateOperation.LessThanOrEqual;
                    break;
                case "gte":
                    op = PredicateOperation.GreaterThanOrEqual;
                    break;
                case "contains":
                    if (isListType)
                    {
                        op = PredicateOperation.ARRAY_CONTAINS;
                    }
                    else
                    {
                        op = PredicateOperation.LIKE;
                        value = $"%{EscapeLikeString((string)value)}%";
                    }

                    break;
                case "notContains":
                    if (isListType)
                    {
                        op = PredicateOperation.NOT_ARRAY_CONTAINS;
                    }
                    else
                    {
                        op = PredicateOperation.NOT_LIKE;
                        value = $"%{EscapeLikeString((string)value)}%";
                    }

                    break;
                case "startsWith":
                    op = PredicateOperation.LIKE;
                    value = $"{EscapeLikeString((string)value)}%";
                    break;
                case "endsWith":
                    op = PredicateOperation.LIKE;
                    value = $"%{EscapeLikeString((string)value)}";
                    break;
                case "isNull":
                    processLiteral = false;
                    bool isNull = (bool)value;
                    op = isNull ? PredicateOperation.IS : PredicateOperation.IS_NOT;
                    value = GQLFilterParser.NullStringValue;
                    break;
                default:
                    throw new NotSupportedException($"Operation {name} on int type not supported.");
            }

            predicates.Push(new PredicateOperand(new Predicate(
                new PredicateOperand(column),
                op,
                new PredicateOperand(processLiteral ? $"{processLiterals(value, column.ColumnName)}" : value.ToString()))
                ));
        }

        return GQLFilterParser.MakeChainPredicate(predicates, PredicateOperation.AND);
    }