How to get oid to create a branch

I basically want to get create a ref through the graphql API but I’m not sure how to get last sha on master to be able to achieve this?

Any help I can get will be highly appreciated

You can use the following:

{
  repository(owner: "user", name: "repo") {
    defaultBranchRef {
      target {
        oid
      }
    }
  }
}

I hope that helps!