Skip to content

Commit

Permalink
Update octokit graphql type dependencies (#228)
Browse files Browse the repository at this point in the history
* Update GraphQL support in base API
  • Loading branch information
hross authored Dec 6, 2019
1 parent 1c12ced commit 5fdab2a
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 81 deletions.
4 changes: 4 additions & 0 deletions packages/github/RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# @actions/github Releases

### 2.0.0

- Upgrade Octokit version to 4.x to include typescript types [#228](https://github.com/actions/toolkit/pull/228)

### 1.1.0

- Accept Octokit.Options in the GitHub constructor [#113](https://github.com/actions/toolkit/pull/113)
Expand Down
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.

6 changes: 4 additions & 2 deletions packages/github/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@actions/github",
"version": "1.1.0",
"version": "2.0.0",
"description": "Actions github lib",
"keywords": [
"github",
Expand All @@ -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
16 changes: 10 additions & 6 deletions packages/github/src/github.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
// 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'

// we need this type to set up a property on the GitHub object
// that has token authorization
// (it is not exported from octokit by default)
import {graphql as GraphQL} from '@octokit/graphql/dist-types/types'

import Octokit from '@octokit/rest'
import * as Context from './context'

Expand All @@ -9,14 +15,12 @@ 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 5fdab2a

Please sign in to comment.