Skip to content

Allow Nested FilterInputType to have isNull check #8177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pedrohugorm opened this issue Mar 25, 2025 · 0 comments
Open

Allow Nested FilterInputType to have isNull check #8177

pedrohugorm opened this issue Mar 25, 2025 · 0 comments

Comments

@pedrohugorm
Copy link

pedrohugorm commented Mar 25, 2025

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
          }
        }
      }
    ) {
      ...
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant