@@ -10,10 +10,8 @@ import {
1010 IntrospectionQuery ,
1111 parse
1212} from "graphql" ;
13- import { Agent , AgentOptions } from "https " ;
13+ import { Agent } from "http " ;
1414import { fetch } from "apollo-env" ;
15- import { URL } from "url" ;
16-
1715import { RemoteServiceConfig } from "../../config" ;
1816import { GraphQLSchemaProvider , SchemaChangeUnsubscribeHandler } from "./base" ;
1917
@@ -23,23 +21,11 @@ export class IntrospectionSchemaProvider implements GraphQLSchemaProvider {
2321 async resolveSchema ( ) {
2422 if ( this . schema ) return this . schema ;
2523 const { skipSSLValidation, url, headers } = this . config ;
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- }
24+ const options : HttpLink . Options = {
25+ uri : url ,
26+ fetch,
27+ ...( skipSSLValidation && { fetchOptions : { agent : new Agent ( ) } } )
28+ } ;
4329
4430 const { data, errors } = ( await toPromise (
4531 linkExecute ( createHttpLink ( options ) , {
0 commit comments