# GraphqlQuery Task

This is a task that calls the GraphQL query API provided by the server. When writing queries, variable handling can be done in two ways, and it is recommended to use Method 2.

Method 1: You can use variables from the scenario context, such as data and variables, including [Script Internal Variables](../concept/script-internal-variables.md). This method is suitable for applying string variables.

```graphql
query {
  fetchWorkOrderHistory(fromDate: "${this.variables.fromDate}", toDate: "${this.variables.toDate}") {
    ...
  }

  searchObjectWithTag(tag: "${this.data.tag}") {
    ...
  }
}
```

Method 2: Specify the variables to be used in `variables` and use the GraphQL variable handling method. The value of `variables` can be specified as an accessor for data in the scenario context. This method is suitable for applying object-type variables.

```graphql
query($filters: [Filter!], $sortings: [Sorting!], $pagination: Pagination, tag: String!) {
  boards(filters: $filters, sortings: $sortings, pagination: $pagination) {
    ...
  }

  searchObjectWithTag(tag: $tag) {
    ...
  }
}
```
