-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
12 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,27 @@ | ||
// Originally pulled from https://github.com/JasonEtco/actions-toolkit/blob/master/src/github.ts | ||
import {graphql} from '@octokit/graphql' | ||
|
||
// we need this type to set up a property on the GitHub object | ||
// that has token authorization | ||
// (it is not exported from oktokit by default) | ||
import {graphql as GraphQL} from '@octokit/graphql/dist-types/types' | ||
|
||
import Octokit from '@octokit/rest' | ||
import * as Context from './context' | ||
import * as Context from './context'; | ||
|
||
// We need this in order to extend Octokit | ||
Octokit.prototype = new Octokit() | ||
Octokit.prototype = new Octokit(); | ||
|
||
export const context = new Context.Context() | ||
export const context = new Context.Context(); | ||
|
||
export class GitHub extends Octokit { | ||
graphql: GraphQL | ||
public graphql: GraphQL; | ||
|
||
constructor(token: string, opts: Omit<Octokit.Options, 'auth'> = {}) { | ||
super({...opts, auth: `token ${token}`}) | ||
super({...opts, auth: `token ${token}`}); | ||
|
||
this.graphql = graphql.defaults({ | ||
headers: {authorization: `token ${token}`} | ||
}) | ||
}); | ||
} | ||
} |