# tasks

```graphql
query Tasks($projectReference: String!) {
  tasks(projectReference: $projectReference) {
    data {
      id
      name
      description
      target
      sourcePath
      editMode
      inputSchema
      outputSchema
      schedulable
    }
    pageInfo {
      hasNextPage
      hasPreviousPage
      startCursor
      endCursor
    }
    diagnostics {
      kind
      sourceKind
      sourcePath
      sourceId
      code
      message
      details
    }
  }
}
```

List the tasks defined in the source of a project, a branch or an environment to find a task to run, schedule or edit; returns every task as one page with the source files that could not be read as tasks. Requires project.runs.read.

## Arguments

| Name                        | Type                | Required | Description                                                                                                                    |
| --------------------------- | ------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `projectReference`          | String!             | Yes      |                                                                                                                                |
| `input`                     | SourceSelectorInput |          |                                                                                                                                |
| `input.sourceTargetKind`    | SourceTargetKind    |          | The source to read; default runtimeTargetKind, else project. One of `project`, `main_branch`, `environment`, `preview_branch`. |
| `input.runtimeTargetKind`   | RuntimeTargetKind   |          | Used as the source to read when sourceTargetKind is omitted. One of `main_branch`, `environment`, `preview_branch`.            |
| `input.targetEnvironmentId` | ID                  |          | Required with the kind environment.                                                                                            |
| `input.targetBranchId`      | ID                  |          | Required with the kind preview\_branch.                                                                                        |

## Variables

```json
{
  "projectReference": "string"
}
```

## Responses

| Status | Description                  |
| ------ | ---------------------------- |
| 200    | The TaskList! in data.tasks. |

## Call it

```bash
curl -X POST "https://api.veryfront.com/graphql" \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "query": "query Tasks($projectReference: String!) {\n  tasks(projectReference: $projectReference) {\n    data {\n      id\n      name\n      description\n      target\n      sourcePath\n      editMode\n      inputSchema\n      outputSchema\n      schedulable\n    }\n    pageInfo {\n      hasNextPage\n      hasPreviousPage\n      startCursor\n      endCursor\n    }\n    diagnostics {\n      kind\n      sourceKind\n      sourcePath\n      sourceId\n      code\n      message\n      details\n    }\n  }\n}",
  "variables": {
    "projectReference": "string"
  }
}'
```

## Example response

```json
{
  "data": {
    "tasks": {
      "data": [
        {
          "id": "string",
          "name": "string",
          "description": "string",
          "target": "string",
          "sourcePath": "string",
          "editMode": "structured",
          "inputSchema": {},
          "outputSchema": {},
          "schedulable": false
        }
      ],
      "pageInfo": {
        "hasNextPage": false,
        "hasPreviousPage": false,
        "startCursor": "string",
        "endCursor": "string"
      },
      "diagnostics": [
        {
          "kind": "string",
          "sourceKind": "string",
          "sourcePath": "string",
          "sourceId": "string",
          "code": "string",
          "message": "string",
          "details": {}
        }
      ]
    }
  }
}
```
