Allow to pass http and https agents (#3263)

This commit is contained in:
Kamil Kisiela 2023-11-03 15:17:07 +01:00 committed by GitHub
parent 5f5294c419
commit 7924ddcd30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
'@graphql-hive/client': minor
---
Allow to pass http and https agents

View file

@ -42,6 +42,14 @@ export interface AgentOptions {
* Custom logger (defaults to console)
*/
logger?: Logger;
/**
* Define a custom http agent to be used when performing http requests
*/
httpAgent?: any;
/**
* Define a custom https agent to be used when performing https requests
*/
httpsAgent?: any;
}
export function createAgent<TEvent, TResult = void>(
@ -72,6 +80,8 @@ export function createAgent<TEvent, TResult = void>(
maxSize: 25,
logger: console,
name: 'hive-client',
httpAgent: undefined,
httpsAgent: undefined,
...pluginOptions,
};
@ -168,6 +178,8 @@ export function createAgent<TEvent, TResult = void>(
},
responseType: 'json',
timeout: options.timeout,
httpAgent: options.httpAgent,
httpsAgent: options.httpsAgent,
})
.catch(error => {
debugLog(`Attempt ${attempt} failed: ${error.message}`);