Skip to content

Allow Nested FilterInputType to have isNull check #8177

@pedrohugorm

Description

@pedrohugorm

Product

Hot Chocolate

Is your feature request related to a problem?

Currently when creating a FilterInputType for a type (example below):

public class AccountFilterInputType : FilterInputType<Account>
{
    protected override void Configure(IFilterInputTypeDescriptor<Account> descriptor)
    {
        descriptor.BindFieldsExplicitly();
        descriptor.Field(a => a.Transactions!.OrderByDescending(t => t.CreateTime).FirstOrDefault())
            .Name("latestTransaction")
            .Type<TransactionFilterInputType>();
    }
}

It's not possible to check if the field value is null.
This is useful when querying for a scenario where you want: Accounts that have no transactions OR accounts that has Count() > 0 transactions.

The current workaround is to create a "hasX" field. Example:

descriptor.Field(a => a.Transactions!.Any())
            .Name("hasTransactions");

The solution you'd like

I'd like to be able to instead of having to create a separate "hasX" field to be able to check if the value is null or not. Example:

query SearchAcounts($workspaceId: UUID!, $userId: UUID!) {
  account(workspaceId: $workspaceId) {
    searchAccounts(
      where: {
        latestTransaction: { 
          isNull: {
             eq: false
          }
        }
      }
    ) {
      ...
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions