Repository: jensneuse/graphql-go-tools
Pull request #208 (2020-04-16 06:21:50)

Bugfix/httpjsondatasource httpclient recreation
This PR will fix the issue that for each HttpJsonDataSource a new http.Client will be used on every request. With this commit the HttpJsonDataSourceFactory can either use the default http client or a user defined http.Client. In either way the client will be re-used across requests.


Patch:
diff --git a/go.mod b/go.mod
index 7b820d00..947925bd 100644
--- a/go.mod
+++ b/go.mod
@@ -27,7 +27,8 @@ require (
 	github.com/stretchr/testify v1.5.1
 	github.com/tidwall/gjson v1.3.5
 	github.com/tidwall/sjson v1.0.4
-	github.com/wasmerio/go-ext-wasm v0.0.0-20191213132134-adcef605ea8e
+	github.com/urfave/cli v1.20.0 // indirect
+	github.com/wasmerio/go-ext-wasm v0.3.1
 	go.uber.org/atomic v1.5.1 // indirect
 	go.uber.org/multierr v1.4.0 // indirect
 	golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect
diff --git a/go.sum b/go.sum
index 7baa1e7d..affe1544 100644
--- a/go.sum
+++ b/go.sum
@@ -17,6 +17,7 @@ github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc
 github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
 github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
 github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
+github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
 github.com/dave/jennifer v1.4.0 h1:tNJFJmLDVTLu+v05mVZ88RINa3vQqnyyWkTKWYz0CwE=
 github.com/dave/jennifer v1.4.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -113,8 +114,10 @@ github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
 github.com/rogpeppe/go-internal v1.3.0 h1:RR9dF3JtopPvtkroDZuVD7qquD0bnHlKSqaQhgwt8yk=
 github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
 github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
+github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
 github.com/sebdah/goldie v0.0.0-20180424091453-8784dd1ab561 h1:IY+sDBJR/wRtsxq+626xJnt4Tw7/ROA9cDIR8MMhWyg=
 github.com/sebdah/goldie v0.0.0-20180424091453-8784dd1ab561/go.mod h1:lvjGftC8oe7XPtyrOidaMi0rp5B9+XY/ZRUynGnuaxQ=
+github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
 github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
 github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
 github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ=
@@ -152,8 +155,11 @@ github.com/tidwall/sjson v1.0.4 h1:UcdIRXff12Lpnu3OLtZvnc03g4vH2suXDXhBwBqmzYg=
 github.com/tidwall/sjson v1.0.4/go.mod h1:bURseu1nuBkFpIES5cz6zBtjmYeOQmEESshn7VpF15Y=
 github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
 github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
+github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
 github.com/wasmerio/go-ext-wasm v0.0.0-20191213132134-adcef605ea8e h1:ztyC+E8g/uepTARRmWz94eZz450GbD1GwZtUPFLhYdQ=
 github.com/wasmerio/go-ext-wasm v0.0.0-20191213132134-adcef605ea8e/go.mod h1:B0C/D0a2vNos7Y3IxQhMpGOY9PCuCKfLvfry33a1cKA=
+github.com/wasmerio/go-ext-wasm v0.3.1 h1:G95XP3fE2FszQSwIU+fHPBYzD0Csmd2ef33snQXNA5Q=
+github.com/wasmerio/go-ext-wasm v0.3.1/go.mod h1:VGyarTzasuS7k5KhSIGpM3tciSZlkP31Mp9VJTHMMeI=
 github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
 go.uber.org/atomic v1.5.0 h1:OI5t8sDa1Or+q8AeE+yKeB/SDYioSHAgcVljj9JIETY=
 go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
diff --git a/pkg/execution/datasource/datasource_graphql.go b/pkg/execution/datasource/datasource_graphql.go
index 35d969d3..ca9e2f82 100644
--- a/pkg/execution/datasource/datasource_graphql.go
+++ b/pkg/execution/datasource/datasource_graphql.go
@@ -353,7 +353,7 @@ func (g *GraphQLDataSource) Resolve(ctx context.Context, args ResolverArgs, out
 
 	res, err := client.Do(request)
 	if err != nil {
-		g.Log.Error("GraphQLDataSource.client.Do",
+		g.Log.Error("GraphQLDataSource.Client.Do",
 			log.Error(err),
 		)
 		return n, err
diff --git a/pkg/execution/datasource/datasource_http_json.go b/pkg/execution/datasource/datasource_http_json.go
index 5b2ec12a..d03d163a 100644
--- a/pkg/execution/datasource/datasource_http_json.go
+++ b/pkg/execution/datasource/datasource_http_json.go
@@ -5,18 +5,20 @@ import (
 	"context"
 	"encoding/json"
 	"fmt"
-	"github.com/buger/jsonparser"
-	log "github.com/jensneuse/abstractlogger"
-	"github.com/jensneuse/graphql-go-tools/pkg/ast"
-	"github.com/jensneuse/graphql-go-tools/pkg/lexer/literal"
-	"github.com/tidwall/gjson"
-	"github.com/tidwall/sjson"
 	"io"
 	"io/ioutil"
 	"net/http"
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/buger/jsonparser"
+	log "github.com/jensneuse/abstractlogger"
+	"github.com/tidwall/gjson"
+	"github.com/tidwall/sjson"
+
+	"github.com/jensneuse/graphql-go-tools/pkg/ast"
+	"github.com/jensneuse/graphql-go-tools/pkg/lexer/literal"
 )
 
 // HttpJsonDataSourceConfig is the configuration object for the HttpJsonDataSource
@@ -41,6 +43,16 @@ type HttpJsonDataSourceConfig struct {
 	StatusCodeTypeNameMappings []StatusCodeTypeNameMapping
 }
 
+func DefaultHttpClient() *http.Client {
+	return &http.Client{
+		Timeout: time.Second * 10,
+		Transport: &http.Transport{
+			MaxIdleConnsPerHost: 1024,
+			TLSHandshakeTimeout: 0 * time.Second,
+		},
+	}
+}
+
 type StatusCodeTypeNameMapping struct {
 	StatusCode int
 	TypeName   string
@@ -52,11 +64,20 @@ type HttpJsonDataSourceConfigHeader struct {
 }
 
 type HttpJsonDataSourcePlannerFactoryFactory struct {
+	client *http.Client
+}
+
+func (h *HttpJsonDataSourcePlannerFactoryFactory) httpClient() *http.Client {
+	if h.client != nil {
+		return h.client
+	}
+	return DefaultHttpClient()
 }
 
-func (h HttpJsonDataSourcePlannerFactoryFactory) Initialize(base BasePlanner, configReader io.Reader) (PlannerFactory, error) {
-	factory := HttpJsonDataSourcePlannerFactory{
-		base: base,
+func (h *HttpJsonDataSourcePlannerFactoryFactory) Initialize(base BasePlanner, configReader io.Reader) (PlannerFactory, error) {
+	factory := &HttpJsonDataSourcePlannerFactory{
+		base:   base,
+		client: h.httpClient(),
 	}
 	err := json.NewDecoder(configReader).Decode(&factory.config)
 	return factory, err
@@ -65,23 +86,27 @@ func (h HttpJsonDataSourcePlannerFactoryFactory) Initialize(base BasePlanner, co
 type HttpJsonDataSourcePlannerFactory struct {
 	base   BasePlanner
 	config HttpJsonDataSourceConfig
+	client *http.Client
 }
 
-func (h HttpJsonDataSourcePlannerFactory) DataSourcePlanner() Planner {
+func (h *HttpJsonDataSourcePlannerFactory) DataSourcePlanner() Planner {
 	return &HttpJsonDataSourcePlanner{
 		BasePlanner:      h.base,
 		dataSourceConfig: h.config,
+		client:           h.client,
 	}
 }
 
 type HttpJsonDataSourcePlanner struct {
 	BasePlanner
 	dataSourceConfig HttpJsonDataSourceConfig
+	client           *http.Client
 }
 
 func (h *HttpJsonDataSourcePlanner) Plan(args []Argument) (DataSource, []Argument) {
 	return &HttpJsonDataSource{
-		Log: h.Log,
+		Log:    h.Log,
+		Client: h.client,
 	}, append(h.Args, args...)
 }
 
@@ -191,7 +216,8 @@ func (h *HttpJsonDataSourcePlanner) LeaveField(ref int) {
 }
 
 type HttpJsonDataSource struct {
-	Log log.Logger
+	Log    log.Logger
+	Client *http.Client
 }
 
 func (r *HttpJsonDataSource) Resolve(ctx context.Context, args ResolverArgs, out io.Writer) (n int, err error) {
@@ -253,14 +279,6 @@ func (r *HttpJsonDataSource) Resolve(ctx context.Context, args ResolverArgs, out
 		log.String("url", url),
 	)
 
-	client := http.Client{
-		Timeout: time.Second * 10,
-		Transport: &http.Transport{
-			MaxIdleConnsPerHost: 1024,
-			TLSHandshakeTimeout: 0 * time.Second,
-		},
-	}
-
 	var bodyReader io.Reader
 	if len(bodyArg) != 0 {
 		bodyArg = bytes.ReplaceAll(bodyArg, literal.BACKSLASH, nil)
@@ -277,9 +295,9 @@ func (r *HttpJsonDataSource) Resolve(ctx context.Context, args ResolverArgs, out
 
 	request.Header = header
 
-	res, err := client.Do(request)
+	res, err := r.Client.Do(request)
 	if err != nil {
-		r.Log.Error("HttpJsonDataSource.Resolve.client.Do",
+		r.Log.Error("HttpJsonDataSource.Resolve.Client.Do",
 			log.Error(err),
 		)
 		return
diff --git a/pkg/execution/datasource/datasource_http_polling_stream.go b/pkg/execution/datasource/datasource_http_polling_stream.go
index 97f81b61..cae557f3 100644
--- a/pkg/execution/datasource/datasource_http_polling_stream.go
+++ b/pkg/execution/datasource/datasource_http_polling_stream.go
@@ -156,7 +156,7 @@ func (h *HttpPollingStreamDataSource) startPolling(ctx context.Context) {
 		default:
 			response, err := h.client.Do(h.request)
 			if err != nil {
-				h.Log.Error("HttpPollingStreamDataSource.startPolling.client.Do",
+				h.Log.Error("HttpPollingStreamDataSource.startPolling.Client.Do",
 					log.Error(err),
 				)
 				return
diff --git a/pkg/execution/datasource/datasource_mqtt.go b/pkg/execution/datasource/datasource_mqtt.go
index 488a025f..4274e998 100644
--- a/pkg/execution/datasource/datasource_mqtt.go
+++ b/pkg/execution/datasource/datasource_mqtt.go
@@ -100,9 +100,9 @@ func (m *MQTTDataSource) Resolve(ctx context.Context, args ResolverArgs, out io.
 	defer func() {
 		select {
 		case <-ctx.Done():
-			m.log.Debug("MQTTDataSource.Resolve.client.Disconnect")
+			m.log.Debug("MQTTDataSource.Resolve.Client.Disconnect")
 			m.client.Disconnect(250)
-			m.log.Debug("MQTTDataSource.Resolve.client.Disconnect.disconnected")
+			m.log.Debug("MQTTDataSource.Resolve.Client.Disconnect.disconnected")
 		default:
 			return
 		}


Test patch:
diff --git a/pkg/execution/datasource_http_json_test.go b/pkg/execution/datasource_http_json_test.go
index dd99a7e0..cb66b1e7 100644
--- a/pkg/execution/datasource_http_json_test.go
+++ b/pkg/execution/datasource_http_json_test.go
@@ -5,14 +5,16 @@ import (
 	"context"
 	"encoding/json"
 	"fmt"
+	"net/http"
+	"net/http/httptest"
+	"testing"
+
 	"github.com/jensneuse/abstractlogger"
+	"github.com/tidwall/gjson"
+
 	"github.com/jensneuse/graphql-go-tools/pkg/ast"
 	"github.com/jensneuse/graphql-go-tools/pkg/execution/datasource"
 	"github.com/jensneuse/graphql-go-tools/pkg/lexer/literal"
-	"github.com/tidwall/gjson"
-	"net/http"
-	"net/http/httptest"
-	"testing"
 )
 
 const httpJsonDataSourceSchema = `
@@ -87,7 +89,7 @@ func TestHttpJsonDataSourcePlanner_Plan(t *testing.T) {
 					},
 				},
 			}
-			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
+			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", &datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
 		},
 		&Object{
 			operationType: ast.OperationTypeQuery,
@@ -99,7 +101,8 @@ func TestHttpJsonDataSourcePlanner_Plan(t *testing.T) {
 							BufferName: "simpleType",
 							Source: &DataSourceInvocation{
 								DataSource: &datasource.HttpJsonDataSource{
-									Log: abstractlogger.Noop{},
+									Log:    abstractlogger.Noop{},
+									Client: datasource.DefaultHttpClient(),
 								},
 								Args: []datasource.Argument{
 									&datasource.StaticVariableArgument{
@@ -201,7 +204,7 @@ func TestHttpJsonDataSourcePlanner_Plan(t *testing.T) {
 					},
 				},
 			}
-			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
+			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", &datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
 		},
 		&Object{
 			operationType: ast.OperationTypeQuery,
@@ -213,7 +216,8 @@ func TestHttpJsonDataSourcePlanner_Plan(t *testing.T) {
 							BufferName: "unionType",
 							Source: &DataSourceInvocation{
 								DataSource: &datasource.HttpJsonDataSource{
-									Log: abstractlogger.Noop{},
+									Log:    abstractlogger.Noop{},
+									Client: datasource.DefaultHttpClient(),
 								},
 								Args: []datasource.Argument{
 									&datasource.StaticVariableArgument{
@@ -347,7 +351,7 @@ func TestHttpJsonDataSourcePlanner_Plan(t *testing.T) {
 					},
 				},
 			}
-			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
+			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", &datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
 		},
 		&Object{
 			operationType: ast.OperationTypeQuery,
@@ -360,6 +364,7 @@ func TestHttpJsonDataSourcePlanner_Plan(t *testing.T) {
 							Source: &DataSourceInvocation{
 								DataSource: &datasource.HttpJsonDataSource{
 									Log: abstractlogger.Noop{},
+									Client: datasource.DefaultHttpClient(),
 								},
 								Args: []datasource.Argument{
 									&datasource.StaticVariableArgument{
@@ -477,6 +482,7 @@ func TestHttpJsonDataSource_Resolve(t *testing.T) {
 			buf := bytes.Buffer{}
 			source := &datasource.HttpJsonDataSource{
 				Log: abstractlogger.Noop{},
+				Client: datasource.DefaultHttpClient(),
 			}
 			args := ResolvedArgs{
 				{
diff --git a/pkg/execution/execution_test.go b/pkg/execution/execution_test.go
index 01814dd5..9f7fbf25 100644
--- a/pkg/execution/execution_test.go
+++ b/pkg/execution/execution_test.go
@@ -249,6 +249,7 @@ func TestExecution(t *testing.T) {
 												},
 												DataSource: &datasource.HttpJsonDataSource{
 													Log: log.NoopLogger,
+													Client: datasource.DefaultHttpClient(),
 												},
 											},
 											BufferName: "friends",
@@ -346,6 +347,7 @@ func TestExecution(t *testing.T) {
 														},
 														DataSource: &datasource.HttpJsonDataSource{
 															Log: log.NoopLogger,
+															Client: datasource.DefaultHttpClient(),
 														},
 													},
 													BufferName: "pets",
@@ -1332,6 +1334,7 @@ func TestExecutor_ObjectVariables(t *testing.T) {
 										},
 										DataSource: &datasource.HttpJsonDataSource{
 											Log: log.NoopLogger,
+											Client: datasource.DefaultHttpClient(),
 										},
 									},
 								},
@@ -1459,6 +1462,7 @@ func TestExecutor_NestedObjectVariables(t *testing.T) {
 							},
 							DataSource: &datasource.HttpJsonDataSource{
 								Log: log.NoopLogger,
+								Client: datasource.DefaultHttpClient(),
 							},
 						},
 					},
@@ -1495,6 +1499,7 @@ func TestExecutor_NestedObjectVariables(t *testing.T) {
 													},
 													DataSource: &datasource.HttpJsonDataSource{
 														Log: log.NoopLogger,
+														Client: datasource.DefaultHttpClient(),
 													},
 												},
 											},
@@ -2074,6 +2079,7 @@ func TestExecutor_HTTPJSONDataSourceWithBody(t *testing.T) {
 						Source: &DataSourceInvocation{
 							DataSource: &datasource.HttpJsonDataSource{
 								Log: log.NoopLogger,
+								Client: datasource.DefaultHttpClient(),
 							},
 							Args: []datasource.Argument{
 								&datasource.StaticVariableArgument{
@@ -2493,6 +2499,7 @@ func TestExecutor_HTTPJSONDataSourceWithBodyComplexPlayload(t *testing.T) {
 						Source: &DataSourceInvocation{
 							DataSource: &datasource.HttpJsonDataSource{
 								Log: log.NoopLogger,
+								Client: datasource.DefaultHttpClient(),
 							},
 							Args: []datasource.Argument{
 								&datasource.StaticVariableArgument{
@@ -2595,6 +2602,7 @@ func TestExecutor_HTTPJSONDataSourceWithHeaders(t *testing.T) {
 						Source: &DataSourceInvocation{
 							DataSource: &datasource.HttpJsonDataSource{
 								Log: log.NoopLogger,
+								Client: datasource.DefaultHttpClient(),
 							},
 							Args: []datasource.Argument{
 								&datasource.StaticVariableArgument{
@@ -2700,6 +2708,7 @@ func TestExecutor_HTTPJSONDataSourceWithPathSelector(t *testing.T) {
 						Source: &DataSourceInvocation{
 							DataSource: &datasource.HttpJsonDataSource{
 								Log: log.NoopLogger,
+								Client: datasource.DefaultHttpClient(),
 							},
 							Args: []datasource.Argument{
 								&datasource.StaticVariableArgument{
diff --git a/pkg/execution/planning_test.go b/pkg/execution/planning_test.go
index c79ca2e6..aa36452a 100644
--- a/pkg/execution/planning_test.go
+++ b/pkg/execution/planning_test.go
@@ -3,22 +3,24 @@ package execution
 import (
 	"encoding/json"
 	"fmt"
+	"math/rand"
+	"reflect"
+	"strings"
+	"testing"
+	"time"
+
 	"github.com/davecgh/go-spew/spew"
 	"github.com/go-test/deep"
 	log "github.com/jensneuse/abstractlogger"
 	"github.com/jensneuse/diffview"
+	"github.com/jensneuse/pipeline/pkg/pipe"
+
 	"github.com/jensneuse/graphql-go-tools/internal/pkg/unsafeparser"
 	"github.com/jensneuse/graphql-go-tools/pkg/ast"
 	"github.com/jensneuse/graphql-go-tools/pkg/astnormalization"
 	"github.com/jensneuse/graphql-go-tools/pkg/execution/datasource"
 	"github.com/jensneuse/graphql-go-tools/pkg/lexer/literal"
 	"github.com/jensneuse/graphql-go-tools/pkg/operationreport"
-	"github.com/jensneuse/pipeline/pkg/pipe"
-	"math/rand"
-	"reflect"
-	"strings"
-	"testing"
-	"time"
 )
 
 func init() {
@@ -393,7 +395,7 @@ func TestPlanner_Plan(t *testing.T) {
 					},
 				},
 			}
-			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
+			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", &datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
 		},
 		&Object{
 			operationType: ast.OperationTypeQuery,
@@ -406,7 +408,8 @@ func TestPlanner_Plan(t *testing.T) {
 								&SingleFetch{
 									Source: &DataSourceInvocation{
 										DataSource: &datasource.HttpJsonDataSource{
-											Log: log.NoopLogger,
+											Log:    log.NoopLogger,
+											Client: datasource.DefaultHttpClient(),
 										},
 										Args: []datasource.Argument{
 											&datasource.StaticVariableArgument{
@@ -455,6 +458,7 @@ func TestPlanner_Plan(t *testing.T) {
 										},
 										DataSource: &datasource.HttpJsonDataSource{
 											Log: log.NoopLogger,
+											Client: datasource.DefaultHttpClient(),
 										},
 									},
 									BufferName: "post",
@@ -541,6 +545,7 @@ func TestPlanner_Plan(t *testing.T) {
 											},
 											DataSource: &datasource.HttpJsonDataSource{
 												Log: log.NoopLogger,
+												Client: datasource.DefaultHttpClient(),
 											},
 										},
 										BufferName: "comments",
@@ -613,7 +618,7 @@ func TestPlanner_Plan(t *testing.T) {
 					},
 				},
 			}
-			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
+			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", &datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
 		},
 		&Object{
 			operationType: ast.OperationTypeQuery,
@@ -626,6 +631,7 @@ func TestPlanner_Plan(t *testing.T) {
 							Source: &DataSourceInvocation{
 								DataSource: &datasource.HttpJsonDataSource{
 									Log: log.NoopLogger,
+									Client: datasource.DefaultHttpClient(),
 								},
 								Args: []datasource.Argument{
 									&datasource.StaticVariableArgument{
@@ -688,7 +694,7 @@ func TestPlanner_Plan(t *testing.T) {
 					},
 				},
 			}
-			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
+			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", &datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
 		},
 		&Object{
 			operationType: ast.OperationTypeQuery,
@@ -701,6 +707,7 @@ func TestPlanner_Plan(t *testing.T) {
 							Source: &DataSourceInvocation{
 								DataSource: &datasource.HttpJsonDataSource{
 									Log: log.NoopLogger,
+									Client: datasource.DefaultHttpClient(),
 								},
 								Args: []datasource.Argument{
 									&datasource.StaticVariableArgument{
@@ -762,7 +769,7 @@ func TestPlanner_Plan(t *testing.T) {
 					},
 				},
 			}
-			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
+			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", &datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
 		},
 		&Object{
 			operationType: ast.OperationTypeQuery,
@@ -775,6 +782,7 @@ func TestPlanner_Plan(t *testing.T) {
 							Source: &DataSourceInvocation{
 								DataSource: &datasource.HttpJsonDataSource{
 									Log: log.NoopLogger,
+									Client: datasource.DefaultHttpClient(),
 								},
 								Args: []datasource.Argument{
 									&datasource.StaticVariableArgument{
@@ -849,7 +857,7 @@ func TestPlanner_Plan(t *testing.T) {
 					},
 				},
 			}
-			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
+			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", &datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
 		},
 		&Object{
 			operationType: ast.OperationTypeQuery,
@@ -862,6 +870,7 @@ func TestPlanner_Plan(t *testing.T) {
 							Source: &DataSourceInvocation{
 								DataSource: &datasource.HttpJsonDataSource{
 									Log: log.NoopLogger,
+									Client: datasource.DefaultHttpClient(),
 								},
 								Args: []datasource.Argument{
 									&datasource.StaticVariableArgument{
@@ -949,7 +958,7 @@ func TestPlanner_Plan(t *testing.T) {
 					},
 				},
 			}
-			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
+			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", &datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
 		},
 		&Object{
 			operationType: ast.OperationTypeQuery,
@@ -962,6 +971,7 @@ func TestPlanner_Plan(t *testing.T) {
 							Source: &DataSourceInvocation{
 								DataSource: &datasource.HttpJsonDataSource{
 									Log: log.NoopLogger,
+									Client: datasource.DefaultHttpClient(),
 								},
 								Args: []datasource.Argument{
 									&datasource.StaticVariableArgument{
@@ -1398,7 +1408,7 @@ func TestPlanner_Plan(t *testing.T) {
 					},
 				},
 			}
-			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
+			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", &datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
 		},
 		&Object{
 			operationType: ast.OperationTypeQuery,
@@ -1432,6 +1442,7 @@ func TestPlanner_Plan(t *testing.T) {
 								},
 								DataSource: &datasource.HttpJsonDataSource{
 									Log: log.NoopLogger,
+									Client: datasource.DefaultHttpClient(),
 								},
 							},
 							BufferName: "restUser",
@@ -1528,7 +1539,7 @@ func TestPlanner_Plan(t *testing.T) {
 				},
 			}
 			panicOnErr(base.RegisterDataSourcePlannerFactory("GraphQLDataSource", datasource.GraphQLDataSourcePlannerFactoryFactory{}))
-			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
+			panicOnErr(base.RegisterDataSourcePlannerFactory("HttpJsonDataSource", &datasource.HttpJsonDataSourcePlannerFactoryFactory{}))
 		},
 		&Object{
 			operationType: ast.OperationTypeQuery,
@@ -1598,6 +1609,7 @@ func TestPlanner_Plan(t *testing.T) {
 											},
 											DataSource: &datasource.HttpJsonDataSource{
 												Log: log.NoopLogger,
+												Client: datasource.DefaultHttpClient(),
 											},
 										},
 										BufferName: "friends",