graphql icon indicating copy to clipboard operation
graphql copied to clipboard

How to make one condition in filter optional?

Open koote opened this issue 1 year ago • 2 comments

I have a query structure defined like this:

type queryAccounts struct {
	Accounts []struct {
            ID string        graphql.String `graphql:"id"`   
            Type string    graphql.String `graphql:"type"`    
            Region string  graphql.String `graphql:"region"`
            Owners string  []graphql.String `graphql:"owners"`
        }`graphql:"allAccountsList(filter:{region: {equalTo: $region}, types:{in: $types}})"`
}

The problem is, the filter [types](types:{in: $types}}) is not always needed. Sometimes i want to query with filter like region=west, types=["test","production","preproduction"], sometimes i just want to query with filter region=east. How to make the filter types optional? thanks.

koote avatar May 16 '24 22:05 koote

Or, is there a way to pass in a full filter string when query?

koote avatar May 16 '24 22:05 koote

@dmitshur Any chance of fixing this as I have the same requirement of making some filters optional but the library does not allow that yet.

sparsh-95 avatar Aug 18 '25 12:08 sparsh-95