Queries

Notifications are the messages informing users of important events happening in their account.

Available queries

Notifications - Returns the list of notifications of the current user

query Notifications(
  $orderBy: [QueryNotificationsOrderByOrderByClause!],
  $first: Int = 10,
  $page: Int
) {
  Notifications(
    orderBy: $orderBy
    first: $first
    page: $page
  ) {
    paginatorInfo {
      total
    }
    data {
      id
      created_at
      read_at
      data
      type
    }
  }
}
{
  "orderBy": [
    {
      "column": "CREATED_AT",
      "order": "DESC"
    }
  ],
  "first": 10,
  "page": 1
}


Available fields

Notification type

id
Unique identifier of the notification
created_at
Creation date of the notification
updated_at
Date of the latest notification modification
read_at
Date at which the notification was read by the user (null if not yet read)
company_id
Identifier of the company the notification belongs to
data
Additional data of the notification (context dependent)
type
Type of the notification


Sorting

You can sort data based on following fields : created_at

query Notifications(
  $orderBy: [QueryNotificationsOrderByOrderByClause!],
  $first: Int = 10,
  $page: Int
) {
  Notifications(
    orderBy: $orderBy
    first: $first
    page: $page
  ) {
    paginatorInfo {
      total
    }
    data {
      id
      created_at
      read_at
      data
      type
    }
  }
}
{
  "orderBy": [
    {
      "column": "CREATED_AT",
      "order": "DESC"
    }
  ],
  "first": 10,
  "page": 1
}

Example of data returned

{
  "data": {
    "Notifications": {
      "paginatorInfo": {
        "total": 1
      },
      "data": [
        {
          "id": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
          "created_at": "2024-05-13 10:42:21",
          "read_at": null,
          "data": {
            "title": "Low stock alert",
            "message": "Product X is out of stock"
          },
          "type": "stock_alert"
        }
      ]
    }
  }
}