shurcooL / githubv4

Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://docs.github.com/en/graphql).
MIT License
1.11k stars 89 forks source link

PullRequest lacks IsDraft field #66

Open BlackVegetable opened 4 years ago

BlackVegetable commented 4 years ago

The IsDraft field appears to exist for PullRequests in the graphql v4 docs:

Screen Shot 2020-05-28 at 9 47 22 AM

However, when querying for it I am given this response: GHE GraphQL query error: Field 'isDraft' doesn't exist on type 'PullRequest' I'm running GHE 2.20.7 and the April 13th, 2020 commit/release of this repo. This information is available via the v3 API.

Googling around a little showed that some folks were having to use a preview header to get this data via v4. But that information was a little dated.

Any suggestions on how we could add support for this here?

dmitshur commented 4 years ago

I'm running GHE 2.20.7

You should use the Versions dropdown to select documentation for that version:

It'll take you to:

https://developer.github.com/enterprise/2.20/v4/object/pullrequest/#isdraft

It's documented for that version that it's currently in preview and requires an Accept header for "Draft Pull Requests Preview" to provided:

https://developer.github.com/enterprise/2.20/v4/previews/#draft-pull-requests-preview

The tracking issue for schema support preview is #34, but there hasn't been recent progress there. You should be able to use a custom http.RoundTripper wrapper to insert that header as an interim solution.

BlackVegetable commented 4 years ago

Adding a RoundTripper with that header definitely did the trick, btw.