Check if commit is inside branch

Hello

I’m trying to find a better way to check if a commit is inside a branch

the only solution I found is to use compare method from api v3

https://developer.github.com/v3/repos/commits/#compare-two-commits

the only problem is that it will return all the diffs, which I don’t want, it could lead to performance issue for large repos.

I tried to find a way with graphql too but without success.

Have you an idea to how return just the ahead/behind stats 

or just true/false status like done with

git branch --contains $COMMIT_ID

?

kind regards

does anyone has a solution for this ?