> For the complete documentation index, see [llms.txt](https://docs.centara.online/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.centara.online/development/graphql.md).

# GraphQL

A data query language used to query data on a high level from within XVAL language code.

Centara data can be accessed using **GraphQL** query and manipulation language.  This simplifies the retrieval of data and eliminates the need to understand the complex data structure below; instead focusing on higher level structure of the retail data.

The picture below shows an example of the relation of data that can be queried using GraphQL.

![](https://2622013076-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LaL-VPZH18nR2GHl90a%2F-LnHWXaIXdHdr-XIz0En%2F-LnHWbEWjcAy2WT9wGde%2FGraphQL2.svg?alt=media\&token=20a68894-b7dd-41bf-87c5-3709b131cab1)

The data relations are more complex than shown in the picture below, but it gives an idea of how the data can be queried.

#### Testing GraphQL queries

It is possible to test GraphQL queris in Centara Server.

1. Click **Admin**, then click **Server information.**
2. From the list of actions, click **Data query**
3. Type in the desired query in the query text box and click **Run** to retrieve the results

Below is an example of a query that retrieves the sum of all transactions grouped by POS and stores.

```
{
    stores {
        id
        name
        pos {
            id
            name
            sum {
                transactions {
                    saleLines {totalLineAmount}
                }
            }
        }
    }
}
```

#### Filtering and different grouping

By default all data is retrieved, but it is possible to apply both a filter and different grouping to every data object.  For example the query below can be used to retrieve data only for a **Store 1** and a three days; **2019-12-21**, **2019-12-22** and **2019-12-23**.

```
{
    stores (filter: { id: { eq:"1"}}) { {
        id
        name
        pos {
            id
            name
            sum {
                transactions (filter: { businessDate: { gt:"2019-12-20", lt:"2019-12-24" }}, groupBy: [businessDate]) { {
                    group {
                        businessDate
                    }
                    sum { saleLines { totalLineAmount } }
                }
            }
        }
    }
}
```

####
