mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-03 20:23:17 +08:00
Update octokit graphql type dependencies (#228)
* Update GraphQL support in base API
This commit is contained in:
36
packages/github/src/@types/@octokit/index.d.ts
vendored
36
packages/github/src/@types/@octokit/index.d.ts
vendored
@@ -1,36 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
declare module '@octokit/graphql' {
|
||||
export interface GraphQlQueryResponse {
|
||||
data: {[key: string]: any} | null
|
||||
errors?: [
|
||||
{
|
||||
message: string
|
||||
path: [string]
|
||||
extensions: {[key: string]: any}
|
||||
locations: [
|
||||
{
|
||||
line: number
|
||||
column: number
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
export interface GraphQLError {
|
||||
message: string
|
||||
locations?: {line: number; column: number}[]
|
||||
path?: (string | number)[]
|
||||
extensions?: {
|
||||
[key: string]: any
|
||||
}
|
||||
}
|
||||
|
||||
export interface Variables {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export function defaults(
|
||||
options: any
|
||||
): (query: string, variables?: Variables) => Promise<GraphQlQueryResponse>
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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}`}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user