# branchMergePreview

```graphql
query BranchMergePreview($branchId: ID!) {
  branchMergePreview(branchId: $branchId) {
    sourceBranch {
      id
      projectId
      name
      baseBranchId
      createdAt
      createdBy
      mergedAt
      mergedBy
      updatedAt
      version
      description
      status
      autoDeleteOnMerge
    }
    targetBranchId
    targetBranchName
    canMerge
    blockedReason
    hasConflicts
    diffs {
      filePath
      fileType
      fileId
      hasConflicts
      conflictCount
      isNew
      isDeleted
      isModified
      baseChanged
      branchChanged
      baseContent
      targetContent
      sourceContent
    }
  }
}
```

Show the file-by-file changes a merge would apply, with conflict regions and contents. Requires project.read.

## Arguments

| Name             | Type | Required | Description                                                                          |
| ---------------- | ---- | -------- | ------------------------------------------------------------------------------------ |
| `branchId`       | ID!  | Yes      | Branch to merge. A missing branch and one the caller cannot read are both not found. |
| `targetBranchId` | ID   |          | Target branch ID; omit for main.                                                     |

## Variables

```json
{
  "branchId": "string"
}
```

## Responses

| Status | Description                                         |
| ------ | --------------------------------------------------- |
| 200    | The BranchMergePreview! in data.branchMergePreview. |

## 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 BranchMergePreview($branchId: ID!) {\n  branchMergePreview(branchId: $branchId) {\n    sourceBranch {\n      id\n      projectId\n      name\n      baseBranchId\n      createdAt\n      createdBy\n      mergedAt\n      mergedBy\n      updatedAt\n      version\n      description\n      status\n      autoDeleteOnMerge\n    }\n    targetBranchId\n    targetBranchName\n    canMerge\n    blockedReason\n    hasConflicts\n    diffs {\n      filePath\n      fileType\n      fileId\n      hasConflicts\n      conflictCount\n      isNew\n      isDeleted\n      isModified\n      baseChanged\n      branchChanged\n      baseContent\n      targetContent\n      sourceContent\n    }\n  }\n}",
  "variables": {
    "branchId": "string"
  }
}'
```

## Example response

```json
{
  "data": {
    "branchMergePreview": {
      "sourceBranch": {
        "id": "string",
        "projectId": "string",
        "name": "string",
        "baseBranchId": "string",
        "createdAt": "string",
        "createdBy": "string",
        "mergedAt": "string",
        "mergedBy": "string",
        "updatedAt": "string",
        "version": 0,
        "description": "string",
        "status": "active",
        "autoDeleteOnMerge": false
      },
      "targetBranchId": "string",
      "targetBranchName": "string",
      "canMerge": false,
      "blockedReason": "string",
      "hasConflicts": false,
      "diffs": [
        {
          "filePath": "string",
          "fileType": "string",
          "fileId": "string",
          "hasConflicts": false,
          "conflictCount": 0,
          "isNew": false,
          "isDeleted": false,
          "isModified": false,
          "baseChanged": false,
          "branchChanged": false,
          "baseContent": "string",
          "targetContent": "string",
          "sourceContent": "string"
        }
      ]
    }
  }
}
```
