> For the complete documentation index, see [llms.txt](https://arif-hanif.gitbook.io/slackclone/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://arif-hanif.gitbook.io/slackclone/server/api/data-modeling/queries/filtering.md).

# Filtering

{% hint style="info" %}
&#x20;**Note**: Be sure to install the `HotChocolate.Types.Filters` NuGet package.
{% endhint %}

Next we will add filtering to the users query, so we can filter on fields provided in the entity.

This is simply done by adding `.UseFiltering()` on the field we want to filter, like seen on  below.

{% code title="./GraphQL/QueryType.cs" %}

```csharp
using HotChocolate.Types;

namespace SlackClone.GraphQL
{
    public class QueryType : ObjectType<Query>
    {
        protected override void Configure(IObjectTypeDescriptor<Query> descriptor)
        {
            descriptor.Field(t => t.GetUsers()).UseFiltering();
            descriptor.Field(t => t.GetUserStatuses());
        }
    }
}
```

{% endcode %}

Now we can run the server again and test what we have added. Reading the schema documentation you can see the filtering capabilities added to users query.

![](https://3683023892-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LurxKF9uo_T_1SndGac%2F-LuzHU8_MSfoyGoQghDN%2F-LuzmXQlwTF_0QcYKKve%2Fimage.png?alt=media\&token=ae0a2c7f-f3c0-4e08-943e-b0e3ec9de336)

Lets test the filtering with the following query in the playground.

```csharp
{
  users(where: { firstName_starts_with: "D" }) {
    id
    firstName
    lastName
    fullName
    email
    username
  }
}
```

If everything went well you should see the following response.

```csharp
{
  "data": {
    "users": [
      {
        "id": "1964199a-e8be-440a-a178-8998d114fd12",
        "firstName": "Donald",
        "lastName": "Trump",
        "fullName": "Donald Trump",
        "email": "dtrump@us.gov",
        "username": "dtrump"
      }
    ]
  }
}
```
