This commit is contained in:
David Kale
2020-09-08 13:25:36 -04:00
parent e4246d2b5b
commit 91fcbb0108
4227 changed files with 416837 additions and 457884 deletions

View File

@@ -4,7 +4,6 @@
[![@latest](https://img.shields.io/npm/v/@octokit/graphql.svg)](https://www.npmjs.com/package/@octokit/graphql)
[![Build Status](https://github.com/octokit/graphql.js/workflows/Test/badge.svg)](https://github.com/octokit/graphql.js/actions?query=workflow%3ATest+branch%3Amaster)
[![Greenkeeper](https://badges.greenkeeper.io/octokit/graphql.js.svg)](https://greenkeeper.io/)
<!-- toc -->
@@ -151,11 +150,10 @@ const { lastIssues } = await graphql(`query lastIssues($owner: String!, $repo: S
}
}`, {
owner: 'octokit',
repo: 'graphql.js'
repo: 'graphql.js',
headers: {
authorization: `token secret123`
}
}
})
```
@@ -176,7 +174,7 @@ const { lastIssues } = await graphql({
}
}`,
owner: 'octokit',
repo: 'graphql.js'
repo: 'graphql.js',
headers: {
authorization: `token secret123`
}

View File

@@ -5,13 +5,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
var request = require('@octokit/request');
var universalUserAgent = require('universal-user-agent');
const VERSION = "4.4.0";
const VERSION = "4.5.4";
class GraphqlError extends Error {
constructor(request, response) {
const message = response.data.errors[0].message;
super(message);
Object.assign(this, response.data);
Object.assign(this, {
headers: response.headers
});
this.name = "GraphqlError";
this.request = request; // Maintains proper stack trace (only available on V8)
@@ -44,7 +47,14 @@ function graphql(request, query, options) {
}, {});
return request(requestOptions).then(response => {
if (response.data.errors) {
const headers = {};
for (const key of Object.keys(response.headers)) {
headers[key] = response.headers[key];
}
throw new GraphqlError(requestOptions, {
headers,
data: response.data
});
}

File diff suppressed because one or more lines are too long

View File

@@ -3,6 +3,7 @@ export class GraphqlError extends Error {
const message = response.data.errors[0].message;
super(message);
Object.assign(this, response.data);
Object.assign(this, { headers: response.headers });
this.name = "GraphqlError";
this.request = request;
// Maintains proper stack trace (only available on V8)

View File

@@ -26,7 +26,12 @@ export function graphql(request, query, options) {
}, {});
return request(requestOptions).then((response) => {
if (response.data.errors) {
const headers = {};
for (const key of Object.keys(response.headers)) {
headers[key] = response.headers[key];
}
throw new GraphqlError(requestOptions, {
headers,
data: response.data,
});
}

View File

@@ -1 +1 @@
export const VERSION = "4.4.0";
export const VERSION = "4.5.4";

View File

@@ -1,7 +1,9 @@
import { ResponseHeaders } from '@octokit/types';
import { GraphQlEndpointOptions, GraphQlQueryResponse } from "./types";
export declare class GraphqlError<T extends GraphQlQueryResponse> extends Error {
export declare class GraphqlError<ResponseData> extends Error {
request: GraphQlEndpointOptions;
constructor(request: GraphQlEndpointOptions, response: {
data: Required<GraphQlQueryResponse>;
headers: ResponseHeaders;
data: Required<GraphQlQueryResponse<ResponseData>>;
});
}

View File

@@ -1,3 +1,3 @@
import { request as Request } from "@octokit/request";
import { RequestParameters, GraphQlQueryResponseData } from "./types";
export declare function graphql(request: typeof Request, query: string | RequestParameters, options?: RequestParameters): Promise<GraphQlQueryResponseData>;
export declare function graphql<ResponseData = GraphQlQueryResponseData>(request: typeof Request, query: string | RequestParameters, options?: RequestParameters): Promise<ResponseData>;

View File

@@ -1,5 +1,4 @@
import { EndpointOptions, RequestParameters as RequestParametersType, EndpointInterface } from "@octokit/types";
import { graphql } from "./graphql";
export declare type GraphQlEndpointOptions = EndpointOptions & {
variables?: {
[key: string]: unknown;
@@ -14,14 +13,14 @@ export interface graphql {
*
* @param {object} endpoint Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
*/
(options: RequestParameters): GraphQlResponse;
<ResponseData>(options: RequestParameters): GraphQlResponse<ResponseData>;
/**
* Sends a GraphQL query request based on endpoint options
*
* @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`.
*/
(query: Query, parameters?: RequestParameters): GraphQlResponse;
<ResponseData>(query: Query, parameters?: RequestParameters): GraphQlResponse<ResponseData>;
/**
* Returns a new `endpoint` with updated route and parameters
*/
@@ -31,12 +30,12 @@ export interface graphql {
*/
endpoint: EndpointInterface;
}
export declare type GraphQlResponse = ReturnType<typeof graphql>;
export declare type GraphQlResponse<ResponseData> = Promise<ResponseData>;
export declare type GraphQlQueryResponseData = {
[key: string]: any;
} | null;
export declare type GraphQlQueryResponse = {
data: GraphQlQueryResponseData;
};
export declare type GraphQlQueryResponse<ResponseData> = {
data: ResponseData;
errors?: [{
message: string;
path: [string];

View File

@@ -1 +1 @@
export declare const VERSION = "4.4.0";
export declare const VERSION = "4.5.4";

View File

@@ -1,13 +1,14 @@
import { request } from '@octokit/request';
import { getUserAgent } from 'universal-user-agent';
const VERSION = "4.4.0";
const VERSION = "4.5.4";
class GraphqlError extends Error {
constructor(request, response) {
const message = response.data.errors[0].message;
super(message);
Object.assign(this, response.data);
Object.assign(this, { headers: response.headers });
this.name = "GraphqlError";
this.request = request;
// Maintains proper stack trace (only available on V8)
@@ -45,7 +46,12 @@ function graphql(request, query, options) {
}, {});
return request(requestOptions).then((response) => {
if (response.data.errors) {
const headers = {};
for (const key of Object.keys(response.headers)) {
headers[key] = response.headers[key];
}
throw new GraphqlError(requestOptions, {
headers,
data: response.data,
});
}

File diff suppressed because one or more lines are too long

View File

@@ -1,8 +1,8 @@
{
"_from": "@octokit/graphql@^4.3.1",
"_id": "@octokit/graphql@4.4.0",
"_id": "@octokit/graphql@4.5.4",
"_inBundle": false,
"_integrity": "sha512-Du3hAaSROQ8EatmYoSAJjzAz3t79t9Opj/WY1zUgxVUGfIKn0AEjg+hlOLscF6fv6i/4y/CeUvsWgIfwMkTccw==",
"_integrity": "sha512-ITpZ+dQc0cXAW1FmDkHJJM+8Lb6anUnin0VB5hLBilnYVdLC0ICFU/KIvT7OXfW9S81DE3U4Vx2EypDG1OYaPA==",
"_location": "/@octokit/graphql",
"_phantomChildren": {},
"_requested": {
@@ -19,18 +19,18 @@
"_requiredBy": [
"/@actions/github"
],
"_resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.4.0.tgz",
"_shasum": "4540b48bbf796b837b311ba6ea5104760db530ca",
"_resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.5.4.tgz",
"_shasum": "c9ef75b0406ebf195bf5f4ed2304a77ed7df27c7",
"_spec": "@octokit/graphql@^4.3.1",
"_where": "/Users/pjquirk/Source/GitHub/actions/labeler/node_modules/@actions/github",
"_where": "/Users/dakale/dev/GitHub/actions/labeler/node_modules/@actions/github",
"bugs": {
"url": "https://github.com/octokit/graphql.js/issues"
},
"bundleDependencies": false,
"dependencies": {
"@octokit/request": "^5.3.0",
"@octokit/types": "^2.0.0",
"universal-user-agent": "^5.0.0"
"@octokit/types": "^5.0.0",
"universal-user-agent": "^6.0.0"
},
"deprecated": false,
"description": "GitHub GraphQL API client for browsers and Node",
@@ -40,8 +40,8 @@
"@pika/plugin-build-web": "^0.9.0",
"@pika/plugin-ts-standard-pkg": "^0.9.0",
"@types/fetch-mock": "^7.2.5",
"@types/jest": "^25.1.0",
"@types/node": "^13.1.0",
"@types/jest": "^26.0.0",
"@types/node": "^14.0.4",
"fetch-mock": "^9.0.0",
"jest": "^25.1.0",
"prettier": "^2.0.0",
@@ -76,5 +76,5 @@
"sideEffects": false,
"source": "dist-src/index.js",
"types": "dist-types/index.d.ts",
"version": "4.4.0"
"version": "4.5.4"
}