@octokit/graphql
Advanced tools
Comparing version 5.0.3 to 5.0.4
@@ -8,3 +8,3 @@ 'use strict'; | ||
const VERSION = "5.0.3"; | ||
const VERSION = "5.0.4"; | ||
@@ -14,3 +14,2 @@ function _buildMessageForResponseErrors(data) { | ||
} | ||
class GraphqlResponseError extends Error { | ||
@@ -22,9 +21,8 @@ constructor(request, headers, response) { | ||
this.response = response; | ||
this.name = "GraphqlResponseError"; // Expose the errors and response data in their shorthand properties. | ||
this.name = "GraphqlResponseError"; | ||
// Expose the errors and response data in their shorthand properties. | ||
this.errors = response.errors; | ||
this.data = response.data; // Maintains proper stack trace (only available on V8) | ||
this.data = response.data; | ||
// Maintains proper stack trace (only available on V8) | ||
/* istanbul ignore next */ | ||
if (Error.captureStackTrace) { | ||
@@ -34,3 +32,2 @@ Error.captureStackTrace(this, this.constructor); | ||
} | ||
} | ||
@@ -46,3 +43,2 @@ | ||
} | ||
for (const key in options) { | ||
@@ -53,3 +49,2 @@ if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key)) continue; | ||
} | ||
const parsedOptions = typeof query === "string" ? Object.assign({ | ||
@@ -63,29 +58,22 @@ query | ||
} | ||
if (!result.variables) { | ||
result.variables = {}; | ||
} | ||
result.variables[key] = parsedOptions[key]; | ||
return result; | ||
}, {}); // workaround for GitHub Enterprise baseUrl set with /api/v3 suffix | ||
}, {}); | ||
// workaround for GitHub Enterprise baseUrl set with /api/v3 suffix | ||
// https://github.com/octokit/auth-app.js/issues/111#issuecomment-657610451 | ||
const baseUrl = parsedOptions.baseUrl || request.endpoint.DEFAULTS.baseUrl; | ||
if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) { | ||
requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, "/api/graphql"); | ||
} | ||
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 GraphqlResponseError(requestOptions, headers, response.data); | ||
} | ||
return response.data.data; | ||
@@ -97,7 +85,5 @@ }); | ||
const newRequest = request.defaults(newDefaults); | ||
const newApi = (query, options) => { | ||
return graphql(newRequest, query, options); | ||
}; | ||
return Object.assign(newApi, { | ||
@@ -104,0 +90,0 @@ defaults: withDefaults.bind(null, newRequest), |
@@ -1,1 +0,1 @@ | ||
export const VERSION = "5.0.3"; | ||
export const VERSION = "5.0.4"; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "5.0.3"; | ||
export declare const VERSION = "5.0.4"; |
import { request } from '@octokit/request'; | ||
import { getUserAgent } from 'universal-user-agent'; | ||
const VERSION = "5.0.3"; | ||
const VERSION = "5.0.4"; | ||
@@ -6,0 +6,0 @@ function _buildMessageForResponseErrors(data) { |
{ | ||
"name": "@octokit/graphql", | ||
"description": "GitHub GraphQL API client for browsers and Node", | ||
"version": "5.0.3", | ||
"version": "5.0.4", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "files": [ |
@@ -225,3 +225,3 @@ # graphql.js | ||
headers: { | ||
authentication: "token secret123", | ||
authorization: "bearer secret123", | ||
}, | ||
@@ -228,0 +228,0 @@ request: { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
380
42238