Open bynov opened 2 years ago
It's not trivial... but it's possible. I use this technique for many libraries that don't provide an interface to do it.
http.Client
,http.RoundTripper
that will log HTTP request and responses,graphql.Client
with a custom http.Client
.The most tricky one is (2):
// "github.com/henvic/httpretty"
logger := &httpretty.Logger{}
httpClient = &http.Client{
Transport: logger.RoundTripper(http.DefaultTransport),
}
gqlClient := graphql.NewClient(endpoint, graphql.WithHTTPClient(httpClient))
Oh, I just discovered there is a simpler way: gqlClient.Log = func(s string) { log.Println(s) }
Hi!
I see errors
So, how I can easily print raw response without changing the library?