Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 2

[GraphQL API] How to create a branch protection that allows force pushes?

Solved! Go to Solution.

I'm migrating from the REST API v3 to the GraphQL API v4.

 

Is there a GraphQL mutation similar to REST API's "PUT /repos/:owner/:repo/branches/:branch/protection" to allow force pushes to the protected branch?

 

With the REST API, I can create a branch protection rule and set allow_force_pushes: true.

 

How can I do this with GraphQL? I don't readily see how with CreateBranchProtectionRuleInput or UpdateBranchProtectionRuleInput.

 

For added context, in the GitHub UI this is the setting I'm trying to change via GraphQL API:

allow-force-pushes.png

 

Thanks

1 Reply
Highlighted
Solution
Copilot Lvl 3
Message 2 of 2

Re: [GraphQL API] How to create a branch protection that allows force pushes?

Per GitHub Support, the GraphQL API doesn't expose this option.

 

Thanks for reaching out and asking us about this! The GraphQL API doesn't currently expose that field today, though it could change in the future. We don't have a timeline for if or when that would happen, though we encourage you to subscribe to our changelog: https://developer.github.com/v4/changelog/

 

As a workaround, we suggest continuing to use the REST API endpoint for updating that setting.