ChilliCream / ChilliCream/graphql-platform

Allow Nested FilterInputType to have `isNull` check

Open
#8,177 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🌶️ hot chocolate Area: Data
Dominant language
C#
Stars
5.8k
Forks
810
Avg merge
15h 39m
Merged PRs (30d)
98

Description

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
          }
        }
      }
    ) {
      ...
    }
  }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how FilterInputType and IFilterInputTypeDescriptor configure the nested latestTransaction field in the AccountFilterInputType example, then compare that path with existing isNull filter handling. Done means nested filter fields can accept the shown isNull: { eq: false } condition without requiring a separate hasTransactions field, with coverage for the null and non-null cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, graphql
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.