Skip to content

Search clients

Request

Advanced client filtering with custom GraphQL where clauses and dynamic ordering

This query provides maximum flexibility for client data retrieval through custom GraphQL-style where clause construction and dynamic ordering specifications. It's designed for complex business requirements that need sophisticated filtering logic.

Key Features:

  • Custom GraphQL where clause construction for unlimited filtering combinations
  • Dynamic order_by specifications supporting multi-field sorting with custom directions
  • Advanced boolean logic combining multiple filter conditions with _and, _or, _not
  • Relationship-based filtering across connected entities (contacts, staff assignments)
  • Custom pagination with flexible pageSize and page controls for any result set size
  • Full access to GraphQL query capabilities through REST interface abstraction
  • Enterprise-grade filtering supporting complex business logic requirements
  • Support for nested queries and conditional logic patterns

Advanced Filtering Capabilities:

  • Boolean Logic: _and, _or, _not operators for complex condition combinations
  • Text Operations: _like, _ilike, _regex for pattern matching and search
  • Comparison Operators: _gt, _gte, _lt, _lte, _eq, _neq for numerical/date comparisons
  • Array Operations: _in, _nin for multi-value filtering and inclusion/exclusion
  • Null Handling: _is_null for empty value detection and filtering
  • Relationship Traversal: Filter on connected entities like contacts and staff
  • Date Ranges: Precision timestamp filtering for time-based analysis
  • Case Sensitivity: Both case-sensitive and case-insensitive text matching

Dynamic Ordering Options:

  • Multi-field Sorting: Order by multiple columns with individual sort directions
  • Relationship Sorting: Sort by connected entity fields (staff names, contact info)
  • Custom Directions: Mix ascending and descending order across different fields
  • Priority Ordering: Define primary, secondary, tertiary sort criteria
  • Date-based Sorting: createdAt, updatedAt for chronological ordering
  • Text Sorting: Alphabetical ordering with locale-aware collation

Real Example:

curl --location 'https://{{host}}/v1/clients/search' \
--header 'Authorization: bearer {{token}} \
--header 'Content-Type: application/json' \
--data '{
  "pageSize": 1,
  "where": {
    "_and": [
      {
        "_or": [
          {
            "name": {
              "_ilike": "%tech%"
            }
          },
          {
            "clientRef": {
              "_ilike": "%45%"
            }
          }
        ]
      },
      {
        "active": {
          "_eq": true
        }
      },
      {
        "createdAt": {
          "_gte": "1900-01-01T00:00:00Z"
        }
      },
      {
        "partnerStaffId": {
          "_in": [
            5,
            6,
            7,
            8
          ]
        }
      }
    ]
  },
  "orderBy": [
    {
      "name": "asc"
    },
    {
      "createdAt": "desc"
    }
  ]
}'
Security
BearerAuth
Bodyapplication/json
pageSizeinteger, [ 1 .. 1000 ]

Maximum number of filtered clients to return

Default:1
Example:1
whereobject

GraphQL-style where clause for complex filtering

Example:
{ "_and": [ {}, {}, {}, {} ] }
orderByArray of objects

Dynamic ordering specifications with multiple fields

Example:
[ { "name": "asc" }, { "createdAt": "desc" } ]
curl -i -X POST \
  https://api.doc.aiwyn.ai/_mock/bundle/gql/v1/clients/search \
  -H 'Authorization: Bearer <YOUR_JWT_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "pageSize": 1,
    "where": {
      "_and": [
        {
          "_or": [
            {
              "name": {
                "_ilike": "%tech%"
              }
            },
            {
              "clientRef": {
                "_ilike": "%45%"
              }
            }
          ]
        },
        {
          "active": {
            "_eq": true
          }
        },
        {
          "createdAt": {
            "_gte": "1900-01-01T00:00:00Z"
          }
        },
        {
          "partnerStaffId": {
            "_in": [
              5,
              6,
              7,
              8
            ]
          }
        }
      ]
    },
    "orderBy": [
      {
        "name": "asc"
      },
      {
        "createdAt": "desc"
      }
    ]
  }'

Responses

Successfully retrieved filtered clients with dynamic ordering

Bodyapplication/json
clientsArray of objects
totalobject
Response
{ "clients": [ {}, {} ], "total": { "aggregate": {} } }