# Sleep Time

Use `sleepTimes` query to get the number of total minutes of sleep the user has logged for the given date range.

### Required Arguments

<table data-header-hidden><thead><tr><th></th><th width="219"></th><th></th></tr></thead><tbody><tr><td>Argument</td><td>Type</td><td>Description</td></tr><tr><td><code>start</code></td><td>Date!</td><td>The start date when the steps will be counted. Use the format: <code>YYYY-MM-DD</code></td></tr><tr><td><code>end</code></td><td>Date!</td><td>The end date when the steps will be counted. Use the format: <code>YYYY-MM-DD</code></td></tr><tr><td><code>first</code></td><td>Int</td><td>Retrieves the first results from the list.</td></tr><tr><td><code>after</code></td><td>String</td><td> It takes the <em>cursor type</em> and retrieves results after that position.</td></tr><tr><td><code>id</code></td><td>ID</td><td>Id of Sleep Time record.</td></tr></tbody></table>

### Available Fields

|                   |          |                                                                                  |
| ----------------- | -------- | -------------------------------------------------------------------------------- |
| Field Name        | Type     | Description                                                                      |
| `dailyGoal`       | Int!     | Daile goal of total sleep time in min.                                           |
| `totalTime`       | Int!     | Total Sleep time on the given dates in min.                                      |
| `hasNextPage`     | Boolean! | Displays whether there are results in the connection after the current segment.  |
| `hasPreviousPage` | Boolean! | Displays whether there are results in the connection before the current segment. |
| `date`            | Date!    | Date the user logged Sleep Time `YYYY-MM-DD`                                     |
| `value`           | Int!     | Total Sleep Time in min.                                                         |
| `source`          | String!  | Source of input, **default** is set to **suggestic**.                            |
| `id`              | ID!      | Id of Sleep Time record.                                                         |

### Example

{% tabs %}
{% tab title="Request" %}

```graphql
query{
  sleepTimes(start:"2022-08-30" end:"2022-09-02"){
   dailyGoal
   totalTime
    pageInfo{
      hasNextPage
      hasPreviousPage
    }
    edges{
      node{
        date
        source
        value
        id
      }
    }
  }
}
```

{% endtab %}

{% tab title="Response" %}

```graphql
{
  "data": {
    "sleepTimes": {
      "dailyGoal": 0,
      "totalTime": 980,
      "pageInfo": {
        "hasNextPage": false,
        "hasPreviousPage": false,
        "startCursor": "T2Zmc2V0OjA=",
        "endCursor": "T2Zmc2V0OjI0"
      },
      "edges": [
        {
          "node": {
            "date": "2022-09-01",
            "source": "Suggestic",
            "value": 480,
            "id": "U2xlZXBUaW1lOjE1"
          }
        },
        {
          "node": {
            "date": "2022-09-02",
            "source": "Suggestic",
            "value": 500,
            "id": "U2xlZXBUaW1lOjE2"
          }
        }
      ]
    }
  }
}
```

{% endtab %}
{% endtabs %}
