# Sleep Quality Score

Use the `sleepQualityScores` query to retrieve the Sleep Quality Scores associated with the user's sleep tracked for the given time range.

Sleep Quality is an index scaling from 0 to 100, where the values above 77 signify good sleep quality, while those below 77 signify poor sleep quality.

### 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 date when the sleep quality score 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 Quality Record.</td></tr><tr><td><code>source</code></td><td>String</td><td>Source of input, <strong>default</strong> is set to <strong>suggestic</strong>.</td></tr></tbody></table>

### Available Fields

|                   |          |                                                                                                                                                                                |
| ----------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Field Name        | Type     | Description                                                                                                                                                                    |
| `average`         | Int!     | Sleep quality average for the given dates, index scaling from 0 to 100, where the values above 77 signify good sleep quality, while those below 77 signify poor sleep quality. |
| `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 of the Sleep Quality Score was logged `YYYY-MM-DD`                                                                                                                        |
| `value`           | Int      | Sleep quality index scaling from 0 to 100, where the values above 77 signify good sleep quality, while those below 77 signify poor sleep quality                               |
| `source`          | String   | Source of input, **default** is set to **suggestic**.                                                                                                                          |
| `id`              | ID       | Id of Sleep Quality Score Record.                                                                                                                                              |

### Example

{% tabs %}
{% tab title="Request" %}
```graphql
query{
  sleepQualityScores(start:"2022-08-30" end:"2022-09-02"){
   average
    pageInfo{
      hasNextPage
      hasPreviousPage
    }
    edges{
      node{
        date
        source
        value
        id
      }
    }
    
  }
}
```
{% endtab %}

{% tab title="Response" %}
```graphql
{
  "data": {
    "sleepQualityScores": {
      "average": 75,
      "pageInfo": {
        "hasNextPage": false,
        "hasPreviousPage": false
      },
      "edges": [
        {
          "node": {
            "date": "2022-09-01",
            "source": "Suggestic",
            "value": 80,
            "id": "U2xlZXBRdWFsaXR5U2NvcmU6MQ=="
          }
        },
        {
          "node": {
            "date": "2022-09-02",
            "source": "Suggestic",
            "value": 70,
            "id": "U2xlZXBRdWFsaXR5U2NvcmU6Mg=="
          }
        }
      ]
    }
  }
}
```
{% endtab %}
{% endtabs %}
