-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Accept Octokit.Options in the GitHub constructor #113
Conversation
@@ -14,8 +14,8 @@ export class GitHub extends Octokit { | |||
variables?: Variables | |||
) => Promise<GraphQlQueryResponse> | |||
|
|||
constructor(token: string) { | |||
super({auth: `token ${token}`}) | |||
constructor(token: string, opts: Omit<Octokit.Options, 'auth'> = {}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but then how would we construct the authorization header for GraphQL requests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Omit
type.