> ## Documentation Index
> Fetch the complete documentation index at: https://veryfront.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Get branch merge preview

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

`branchMergePreview(branchId: ID!, targetBranchId: ID): BranchMergePreview!`

Requires project.read.

## Arguments

| Argument | Type | Required | Description |
| - | - | - | - |
| `branchId` | [`ID!`](https://veryfront.com/docs/cloud/graphql/types/id) | Yes | Branch to merge. A missing branch and one the caller cannot read are both not found. |
| `targetBranchId` | [`ID`](https://veryfront.com/docs/cloud/graphql/types/id) | No | Target branch ID; omit for main. |

## Response

Returns [`BranchMergePreview!`](https://veryfront.com/docs/cloud/graphql/types/branchmergepreview). Open the type for its fields and nested types.

| Field | Type | Description |
| - | - | - |
| `sourceBranch` | [`Branch!`](https://veryfront.com/docs/cloud/graphql/types/branch) | |
| `targetBranchId` | [`ID`](https://veryfront.com/docs/cloud/graphql/types/id) | Branch that receives the merge, or null for main. |
| `targetBranchName` | [`String!`](https://veryfront.com/docs/cloud/graphql/types/string) | |
| `canMerge` | [`Boolean!`](https://veryfront.com/docs/cloud/graphql/types/boolean) | True only when blockedReason is null, merge policies pass and no file has conflicts. Advisory: the merge checks these conditions again. |
| `blockedReason` | [`String`](https://veryfront.com/docs/cloud/graphql/types/string) | Precondition that blocks the merge, such as a merged or closed branch, or a target that is the source branch or is closed; null when none does. A target that is missing or in another project is a not found error. |
| `hasConflicts` | [`Boolean!`](https://veryfront.com/docs/cloud/graphql/types/boolean) | |
| `diffs` | [`[BranchMergeFileDiff!]!`](https://veryfront.com/docs/cloud/graphql/types/branchmergefilediff) | |

Types marked with `!` cannot be null. Lists use `[Type]` notation. The [type index](https://veryfront.com/docs/cloud/graphql/schema.md) lists all published input and response types.

## Example

```graphql title="query.graphql" theme={null}
query BranchMergePreview($branchId: ID!, $targetBranchId: ID) {
  branchMergePreview(branchId: $branchId, targetBranchId: $targetBranchId) {
    blockedReason
    canMerge
    hasConflicts
    targetBranchId
    targetBranchName
  }
}
```

```json title="variables.json" theme={null}
{
  "branchId": "00000000-0000-4000-8000-000000000001"
}
```

<details>
  <summary>Try this query</summary>

  Calls use `https://api.veryfront.com/graphql`. Replace sample values with resources you can access. See [Authentication](https://veryfront.com/docs/cloud/authentication.md) for credentials and permissions.

  Bearer token or API key

  Stored in this tab's session. Clear credential

  Query

  Variables (JSON)
</details>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.