graphql icon indicating copy to clipboard operation
graphql copied to clipboard

Allow providing a custom request factory

Open andig opened this issue 2 years ago • 3 comments

This PR allows customizing the requests sent for APIs that require additional headers.

Replace #47, #48, #49, https://github.com/shurcooL/graphql/pull/64, #68.

This is not the most beautiful solution but offers the highest amount of customizing the request with the least amount of added lines of code. Making the request factory a private member and optional NewClient parameter would be a further option.

/cc @dmitshur

andig avatar Jul 25 '21 16:07 andig

how do I provide my own request factory?

fi0 avatar Jul 29 '21 13:07 fi0

I've kept it simple. After creating the client you would simply replace client.RequestFactory with a custom func(method, url string, body io.Reader) (*http.Request, error).

andig avatar Jul 29 '21 15:07 andig

Ping @dmitshur

andig avatar Feb 03 '23 10:02 andig