@octokit/graphql
Advanced tools
Comparing version 4.5.5 to 4.5.6
@@ -8,3 +8,3 @@ 'use strict'; | ||
const VERSION = "4.5.5"; | ||
const VERSION = "4.5.6"; | ||
@@ -34,8 +34,12 @@ class GraphqlError extends Error { | ||
function graphql(request, query, options) { | ||
options = typeof query === "string" ? options = Object.assign({ | ||
if (typeof query === "string" && options && "query" in options) { | ||
return Promise.reject(new Error(`[@octokit/graphql] "query" cannot be used as variable name`)); | ||
} | ||
const parsedOptions = typeof query === "string" ? Object.assign({ | ||
query | ||
}, options) : options = query; | ||
const requestOptions = Object.keys(options).reduce((result, key) => { | ||
}, options) : query; | ||
const requestOptions = Object.keys(parsedOptions).reduce((result, key) => { | ||
if (NON_VARIABLE_OPTIONS.includes(key)) { | ||
result[key] = options[key]; | ||
result[key] = parsedOptions[key]; | ||
return result; | ||
@@ -48,3 +52,3 @@ } | ||
result.variables[key] = options[key]; | ||
result.variables[key] = parsedOptions[key]; | ||
return result; | ||
@@ -54,3 +58,3 @@ }, {}); // workaround for GitHub Enterprise baseUrl set with /api/v3 suffix | ||
const baseUrl = options.baseUrl || request.endpoint.DEFAULTS.baseUrl; | ||
const baseUrl = parsedOptions.baseUrl || request.endpoint.DEFAULTS.baseUrl; | ||
@@ -57,0 +61,0 @@ if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) { |
@@ -13,9 +13,9 @@ import { GraphqlError } from "./error"; | ||
export function graphql(request, query, options) { | ||
options = | ||
typeof query === "string" | ||
? (options = Object.assign({ query }, options)) | ||
: (options = query); | ||
const requestOptions = Object.keys(options).reduce((result, key) => { | ||
if (typeof query === "string" && options && "query" in options) { | ||
return Promise.reject(new Error(`[@octokit/graphql] "query" cannot be used as variable name`)); | ||
} | ||
const parsedOptions = typeof query === "string" ? Object.assign({ query }, options) : query; | ||
const requestOptions = Object.keys(parsedOptions).reduce((result, key) => { | ||
if (NON_VARIABLE_OPTIONS.includes(key)) { | ||
result[key] = options[key]; | ||
result[key] = parsedOptions[key]; | ||
return result; | ||
@@ -26,3 +26,3 @@ } | ||
} | ||
result.variables[key] = options[key]; | ||
result.variables[key] = parsedOptions[key]; | ||
return result; | ||
@@ -32,3 +32,3 @@ }, {}); | ||
// https://github.com/octokit/auth-app.js/issues/111#issuecomment-657610451 | ||
const baseUrl = options.baseUrl || request.endpoint.DEFAULTS.baseUrl; | ||
const baseUrl = parsedOptions.baseUrl || request.endpoint.DEFAULTS.baseUrl; | ||
if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) { | ||
@@ -35,0 +35,0 @@ requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, "/api/graphql"); |
@@ -1,1 +0,1 @@ | ||
export const VERSION = "4.5.5"; | ||
export const VERSION = "4.5.6"; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "4.5.5"; | ||
export declare const VERSION = "4.5.6"; |
import { request } from '@octokit/request'; | ||
import { getUserAgent } from 'universal-user-agent'; | ||
const VERSION = "4.5.5"; | ||
const VERSION = "4.5.6"; | ||
@@ -33,9 +33,9 @@ class GraphqlError extends Error { | ||
function graphql(request, query, options) { | ||
options = | ||
typeof query === "string" | ||
? (options = Object.assign({ query }, options)) | ||
: (options = query); | ||
const requestOptions = Object.keys(options).reduce((result, key) => { | ||
if (typeof query === "string" && options && "query" in options) { | ||
return Promise.reject(new Error(`[@octokit/graphql] "query" cannot be used as variable name`)); | ||
} | ||
const parsedOptions = typeof query === "string" ? Object.assign({ query }, options) : query; | ||
const requestOptions = Object.keys(parsedOptions).reduce((result, key) => { | ||
if (NON_VARIABLE_OPTIONS.includes(key)) { | ||
result[key] = options[key]; | ||
result[key] = parsedOptions[key]; | ||
return result; | ||
@@ -46,3 +46,3 @@ } | ||
} | ||
result.variables[key] = options[key]; | ||
result.variables[key] = parsedOptions[key]; | ||
return result; | ||
@@ -52,3 +52,3 @@ }, {}); | ||
// https://github.com/octokit/auth-app.js/issues/111#issuecomment-657610451 | ||
const baseUrl = options.baseUrl || request.endpoint.DEFAULTS.baseUrl; | ||
const baseUrl = parsedOptions.baseUrl || request.endpoint.DEFAULTS.baseUrl; | ||
if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) { | ||
@@ -55,0 +55,0 @@ requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, "/api/graphql"); |
{ | ||
"name": "@octokit/graphql", | ||
"description": "GitHub GraphQL API client for browsers and Node", | ||
"version": "4.5.5", | ||
"version": "4.5.6", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "files": [ |
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
37571
336