Can we use HttpURLConnection with ApolloClient instead of OkHttpClient?

I have a secure http connection to my GraphQL Endpoint using HttpURLConnection . How can i use HttpURLConnection with ApolloClient, instead of okHttpClient ?

Is there any way to convert an Object of HttpURLConnection to okHttpClient ? Or How do i use my HttpURLConnection with httpEngine of ApolloClient ?


val apolloClient = ApolloClient.Builder()

I worked around this by iterating through HttpUrlConnection request/header parametres and setting it in the builder

ApolloClient.Builder builder = ApolloClient.builder().serverUrl(graphQlURL);
        for (Map.Entry<String, List<String>> entries : httpURLConnection.getRequestProperties().entrySet()) {
            String values = "";
            for (String value : entries.getValue()) {
                values += value + ",";
            Log.d("Request", entries.getKey() + " - " +  values );
        ApolloClient apolloClient =;