Skip to content

Commit

Permalink
Update GraphQL support in base API
Browse files Browse the repository at this point in the history
  • Loading branch information
hross committed Nov 22, 2019
1 parent 5c89429 commit 45f087f
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 81 deletions.
84 changes: 52 additions & 32 deletions packages/github/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion packages/github/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
"scripts": {
"test": "jest",
"build": "tsc",
"format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts",
"tsc": "tsc"
},
"bugs": {
"url": "https://github.com/actions/toolkit/issues"
},
"dependencies": {
"@octokit/graphql": "^2.0.1",
"@octokit/graphql": "^4.3.1",
"@octokit/rest": "^16.15.0"
},
"devDependencies": {
Expand Down
36 changes: 0 additions & 36 deletions packages/github/src/@types/@octokit/index.d.ts

This file was deleted.

7 changes: 2 additions & 5 deletions packages/github/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ export class Context {
readFileSync(process.env.GITHUB_EVENT_PATH, {encoding: 'utf8'})
)
} else {
process.stdout.write(
`GITHUB_EVENT_PATH ${
process.env.GITHUB_EVENT_PATH
} does not exist${EOL}`
)
const path = process.env.GITHUB_EVENT_PATH
process.stdout.write(`GITHUB_EVENT_PATH ${path} does not exist${EOL}`)
}
}
this.eventName = process.env.GITHUB_EVENT_NAME as string
Expand Down
12 changes: 5 additions & 7 deletions packages/github/src/github.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Originally pulled from https://github.com/JasonEtco/actions-toolkit/blob/master/src/github.ts
import {GraphQlQueryResponse, Variables, defaults} from '@octokit/graphql'
import {graphql} from '@octokit/graphql'
import {graphql as GraphQL} from '@octokit/graphql/dist-types/types'
import Octokit from '@octokit/rest'
import * as Context from './context'

Expand All @@ -9,14 +10,11 @@ Octokit.prototype = new Octokit()
export const context = new Context.Context()

export class GitHub extends Octokit {
graphql: (
query: string,
variables?: Variables
) => Promise<GraphQlQueryResponse>

graphql: GraphQL
constructor(token: string, opts: Omit<Octokit.Options, 'auth'> = {}) {
super({...opts, auth: `token ${token}`})
this.graphql = defaults({

this.graphql = graphql.defaults({
headers: {authorization: `token ${token}`}
})
}
Expand Down

0 comments on commit 45f087f

Please sign in to comment.