machinebox / graphql

Simple low-level GraphQL HTTP client for Go
https://blog.machinebox.io/a-graphql-client-library-for-go-5bffd0455878
Apache License 2.0
933 stars 217 forks source link

Accept an interface instead of *http.Client in WithHTTPClient #76

Open arthurdarcet opened 1 year ago

arthurdarcet commented 1 year ago

The WithHTTPClient helper is not really useful if you have to return a real *http.Client. Using an interface here allows us to create custom implementations that can intercept the request and whatever we need with it (such as adding headers)

(adding headers is technically feasible by using a custom Transport wrapped in a real http.Client, but that's not really recommended)