graphql-dotnet / graphql-dotnet/graphql-client

Conditionally exclude filters

Open
#669 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
648
Forks
136
PR merge metrics
No merged PRs in 30d

Description

# Issue

Some GraphQL APIs don’t handle optional filters properly — when a filter is not needed, it should be **omitted** from the query. Instead, we’re forced to rebuild the query string if we don’t need that filter.

I want to reuse a query like this:

```graphql
query($page: Int!, $size: Int!, $categoryId: String) {
items(page: $page, size: $size, filter: { category: { eq: $categoryId } }) {
id
}
}
```

If `categoryId` is not provided, it should be removed from the query entirely, not passed as null.

# Request

Is there a better way to handle this that I’m missing?

It would be helpful if GraphQLRequest could:

* Allow us to conditionally include/exclude filters based on the variable values.
* Provide a way to compose queries without having to rebuild them from scratch each time.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.