Skip to content

Commit dacac6f

Browse files
committed
Update GraphQL support in base API
1 parent 5c89429 commit dacac6f

File tree

5 files changed

+67
-80
lines changed

5 files changed

+67
-80
lines changed

packages/github/package-lock.json

+52-32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/github/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@
2727
"scripts": {
2828
"test": "jest",
2929
"build": "tsc",
30+
"format": "prettier --write **/*.ts",
31+
"format-check": "prettier --check **/*.ts",
3032
"tsc": "tsc"
3133
},
3234
"bugs": {
3335
"url": "https://github.com/actions/toolkit/issues"
3436
},
3537
"dependencies": {
36-
"@octokit/graphql": "^2.0.1",
38+
"@octokit/graphql": "^4.3.1",
3739
"@octokit/rest": "^16.15.0"
3840
},
3941
"devDependencies": {

packages/github/src/@types/@octokit/index.d.ts

-36
This file was deleted.

packages/github/src/context.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ export class Context {
2727
readFileSync(process.env.GITHUB_EVENT_PATH, {encoding: 'utf8'})
2828
)
2929
} else {
30-
process.stdout.write(
31-
`GITHUB_EVENT_PATH ${
32-
process.env.GITHUB_EVENT_PATH
33-
} does not exist${EOL}`
34-
)
30+
const path = process.env.GITHUB_EVENT_PATH
31+
process.stdout.write(`GITHUB_EVENT_PATH ${path} does not exist${EOL}`)
3532
}
3633
}
3734
this.eventName = process.env.GITHUB_EVENT_NAME as string

packages/github/src/github.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
// Originally pulled from https://github.com/JasonEtco/actions-toolkit/blob/master/src/github.ts
2-
import {GraphQlQueryResponse, Variables, defaults} from '@octokit/graphql'
2+
import {graphql} from '@octokit/graphql'
3+
4+
// we need this type to set up a property on the GitHub object
5+
// that has token authorization
6+
// (it is not exported from oktokit by default)
7+
import {graphql as GraphQL} from '@octokit/graphql/dist-types/types'
8+
39
import Octokit from '@octokit/rest'
410
import * as Context from './context'
511

@@ -9,14 +15,12 @@ Octokit.prototype = new Octokit()
915
export const context = new Context.Context()
1016

1117
export class GitHub extends Octokit {
12-
graphql: (
13-
query: string,
14-
variables?: Variables
15-
) => Promise<GraphQlQueryResponse>
18+
public graphql: GraphQL
1619

1720
constructor(token: string, opts: Omit<Octokit.Options, 'auth'> = {}) {
1821
super({...opts, auth: `token ${token}`})
19-
this.graphql = defaults({
22+
23+
this.graphql = graphql.defaults({
2024
headers: {authorization: `token ${token}`}
2125
})
2226
}

0 commit comments

Comments
 (0)