Here are two queries that look up information about a pull request via GitHub's GraphQL API v4. The first looks up a pull request by number, the second looks up a pull request by ref (i.e. commit hash, branch name, tag name).
While it is trivial to use the RESTful v3 API to look up a pull request by number, the GraphQL API is the only way to do the same thing for an arbitrary reference in a single HTTP request.
These took a bit of trial and error in the GitHub's GraphQL Explorer and various support threads to get right, so I'm putting them up here for posterity.