> Filter conditions, AND/OR logic, and sorting in raw GraphQL queries

# GraphQL Filtering

Pass filters to list queries through the `filter` input. For the SDK filter syntax, see
[Filtering & Sorting](/data/filtering-and-sorting).

## Conditions

Each condition specifies a field, operator, and value:

```graphql filename="query"
query {
  customerList(
    filter: {
      query: [{
        condition: {
          field: "name"
          operator: ilike
          value: "%john%"
        }
      }]
    }
  ) {
    data { id name }
  }
}
```

The operator set matches the SDK operators: see the
[operator tables](/data/filtering-and-sorting#operators). In GraphQL, operators are enum values
without quotes (`operator: ilike`).

## AND conditions

```graphql filename="query"
query {
  customerList(
    filter: {
      query: [{
        and: [
          {
            condition: {
              field: "status"
              operator: equal
              value: "active"
            }
          }
          {
            condition: {
              field: "created_at"
              operator: greaterThan
              value: "2024-01-01"
            }
          }
        ]
      }]
    }
  ) {
    data { id name status created_at }
  }
}
```

## OR conditions

```graphql filename="query"
query {
  customerList(
    filter: {
      query: [{
        or: [
          {
            condition: {
              field: "status"
              operator: equal
              value: "active"
            }
          }
          {
            condition: {
              field: "status"
              operator: equal
              value: "pending"
            }
          }
        ]
      }]
    }
  ) {
    data { id name status }
  }
}
```

## Filtering relations

Use dot notation to filter by related fields:

```graphql filename="query"
query {
  orderList(
    filter: {
      query: [{
        condition: {
          field: "customer.name"
          operator: ilike
          value: "%acme%"
        }
      }]
    }
  ) {
    data {
      id
      total
      customer {
        data { name }
      }
    }
  }
}
```

## Sorting

```graphql filename="query"
query {
  customerList(
    filter: {
      sortby: [
        { field: "status", order: asc }
        { field: "created_at", order: desc }
      ]
    }
  ) {
    data { id name status created_at }
  }
}
```

Sorting by related fields also uses dot notation (`field: "customer.name"`).
