apollo-datasource-http
Advanced tools
Comparing version 0.9.2 to 0.9.3
@@ -18,2 +18,3 @@ /// <reference types="node" /> | ||
export declare type RequestOptions = { | ||
query?: Dictionary<string | number>; | ||
body?: string | Buffer | Uint8Array | Readable | null; | ||
@@ -25,2 +26,3 @@ headers?: Dictionary<string>; | ||
headers: Dictionary<string>; | ||
query?: Dictionary<string | number>; | ||
}; | ||
@@ -51,2 +53,3 @@ export declare type Response<TResult> = { | ||
constructor(baseURL: string, options?: HTTPDataSourceOptions | undefined); | ||
private buildQueryString; | ||
initialize(config: DataSourceConfig<TContext>): void; | ||
@@ -53,0 +56,0 @@ protected isResponseOk(statusCode: number): boolean; |
@@ -14,2 +14,3 @@ "use strict"; | ||
const apollo_server_errors_1 = require("apollo-server-errors"); | ||
const url_1 = require("url"); | ||
function apolloKeyValueCacheToKeyv(cache) { | ||
@@ -50,2 +51,14 @@ return { | ||
} | ||
buildQueryString(query) { | ||
const params = new url_1.URLSearchParams(); | ||
for (const key in query) { | ||
if (Object.prototype.hasOwnProperty.call(query, key)) { | ||
const value = query[key]; | ||
if (value !== undefined) { | ||
params.append(key, value.toString()); | ||
} | ||
} | ||
} | ||
return params.toString(); | ||
} | ||
initialize(config) { | ||
@@ -148,2 +161,5 @@ this.context = config.context; | ||
async request(request) { | ||
if (request?.query) { | ||
request.path = request.path + '?' + this.buildQueryString(request.query); | ||
} | ||
const cacheKey = this.onCacheKeyCalculation(request); | ||
@@ -150,0 +166,0 @@ const ttlCacheEnabled = request.requestCache; |
{ | ||
"name": "apollo-datasource-http", | ||
"version": "0.9.2", | ||
"version": "0.9.3", | ||
"author": "Dustin Deus <deusdustin@gmail.com>", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
25738
260