Use @actions/[email protected] to invoke GraphQL for GHES compatibility
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import {from, Observable, merge, throwError, of} from 'rxjs'
|
||||
import {graphql} from '@octokit/graphql'
|
||||
import {catchError, map, tap} from 'rxjs/operators'
|
||||
import {GraphQlQueryResponse} from '@octokit/graphql/dist-types/types'
|
||||
import {graphql} from './graphql'
|
||||
|
||||
export interface DeletePackageVersionMutationResponse {
|
||||
deletePackageVersion: {
|
||||
@@ -21,10 +21,9 @@ export function deletePackageVersion(
|
||||
token: string
|
||||
): Observable<boolean> {
|
||||
return from(
|
||||
graphql(mutation, {
|
||||
graphql(token, mutation, {
|
||||
packageVersionId,
|
||||
headers: {
|
||||
authorization: `token ${token}`,
|
||||
Accept: 'application/vnd.github.package-deletes-preview+json'
|
||||
}
|
||||
}) as Promise<DeletePackageVersionMutationResponse>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {graphql} from '@octokit/graphql'
|
||||
import {GraphQlQueryResponse} from '@octokit/graphql/dist-types/types'
|
||||
import {Observable, from, throwError} from 'rxjs'
|
||||
import {catchError, map} from 'rxjs/operators'
|
||||
import {graphql} from './graphql'
|
||||
|
||||
export interface VersionInfo {
|
||||
id: string
|
||||
@@ -52,13 +52,12 @@ export function queryForOldestVersions(
|
||||
token: string
|
||||
): Observable<GetVersionsQueryResponse> {
|
||||
return from(
|
||||
graphql(query, {
|
||||
graphql(token, query, {
|
||||
owner,
|
||||
repo,
|
||||
package: packageName,
|
||||
last: numVersions,
|
||||
headers: {
|
||||
authorization: `token ${token}`,
|
||||
Accept: 'application/vnd.github.packages-preview+json'
|
||||
}
|
||||
}) as Promise<GetVersionsQueryResponse>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import {GitHub} from '@actions/github'
|
||||
import {GraphQlQueryResponseData} from '@octokit/graphql/dist-types/types'
|
||||
import {RequestParameters} from '@octokit/types/dist-types/RequestParameters'
|
||||
|
||||
/**
|
||||
* Sends a GraphQL query request based on endpoint options
|
||||
*
|
||||
* @param {string} token Auth token
|
||||
* @param {string} query GraphQL query. Example: `'query { viewer { login } }'`.
|
||||
* @param {object} parameters URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
|
||||
*/
|
||||
export async function graphql(
|
||||
token: string,
|
||||
query: string,
|
||||
parameters: RequestParameters
|
||||
): Promise<GraphQlQueryResponseData> {
|
||||
const github = new GitHub(token)
|
||||
return await github.graphql(query, parameters)
|
||||
}
|
||||
Reference in New Issue
Block a user