@@ -10,8 +10,10 @@ import {
1010 IntrospectionQuery ,
1111 parse
1212} from "graphql" ;
13- import { Agent } from "http " ;
13+ import { Agent , AgentOptions } from "https " ;
1414import { fetch } from "apollo-env" ;
15+ import { URL } from "url" ;
16+
1517import { RemoteServiceConfig } from "../../config" ;
1618import { GraphQLSchemaProvider , SchemaChangeUnsubscribeHandler } from "./base" ;
1719
@@ -21,11 +23,23 @@ export class IntrospectionSchemaProvider implements GraphQLSchemaProvider {
2123 async resolveSchema ( ) {
2224 if ( this . schema ) return this . schema ;
2325 const { skipSSLValidation, url, headers } = this . config ;
24- const options : HttpLink . Options = {
25- uri : url ,
26- fetch,
27- ...( skipSSLValidation && { fetchOptions : { agent : new Agent ( ) } } )
28- } ;
26+ let options : HttpLink . Options = { uri : url , fetch } ;
27+
28+ if ( skipSSLValidation ) {
29+ const urlObject = new URL ( url ) ;
30+ const host = urlObject . host ;
31+ const port = + urlObject . port || 443 ;
32+
33+ const agentOptions : AgentOptions = {
34+ host : host ,
35+ port : port ,
36+ rejectUnauthorized : false
37+ } ;
38+
39+ const agent = new Agent ( agentOptions ) ;
40+
41+ options . fetchOptions = { agent : agent } ;
42+ }
2943
3044 const { data, errors } = ( await toPromise (
3145 linkExecute ( createHttpLink ( options ) , {
0 commit comments