Accept Octokit.Options in the GitHub constructor#113
Conversation
|
|
||
| constructor(token: string) { | ||
| super({auth: `token ${token}`}) | ||
| constructor(token: string, opts: Omit<Octokit.Options, 'auth'> = {}) { |
There was a problem hiding this comment.
Rather than omitting auth, can we just overload the constructor to something like:
constructor(token: string) { ... }
constructor(opts = {}) { ... }
That would also resolve #106
There was a problem hiding this comment.
True, but then how would we construct the authorization header for GraphQL requests?
|
Might also be good to doc this as an option in https://github.com/actions/toolkit/blob/master/packages/github/README.md |
|
The more I think about it, the more I like the simplicity of forcing a token to be provided and then accepting token-less options as a second argument. I think a token with no opts will be 99% of use. For cases where more complex authorization is required (as is in the case of @josephperrott's issue), it seems just as easy to use @octokit/rest directly. |
damccorm
left a comment
There was a problem hiding this comment.
Ok, I think I'm on board with that plan. LGTM (pending docs)
This adds an optional object of Octokit client options to the GitHub constructor. This allows for debugging, API previews, etc.
This PR also bumps TypeScript to 3.6.2 so that I can use the
Omittype.