Skip to content
Discussion options

You must be logged in to vote

You’re running into a limitation of the GitHub GraphQL schema, that error is actually telling you the whole story 🙂

deleteBranchOnMerge is a field on the Repository object, but it’s not part of UpdateRepositoryInput, so there’s currently no way to set it via the updateRepository GraphQL mutation. In other words, in GraphQL it’s effectively read-only.

To turn on “Automatically delete head branches” programmatically, you have to use the REST API instead of GraphQL. The setting is exposed there as delete_branch_on_merge on the repository update endpoint:

PATCH /repos/{owner}/{repo}

Example with curl:

curl -X PATCH \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer YO…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by drmcclelland
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API and Webhooks Discussions related to GitHub's APIs or Webhooks Question Ask and answer questions about GitHub features and usage
2 participants