graphql-client icon indicating copy to clipboard operation
graphql-client copied to clipboard

default timeout configuration needed

Open krishnarohitreddy opened this issue 6 years ago • 2 comments

@josh Is their a way to configure Session open_timeout, read_timeout values?

krishnarohitreddy avatar Nov 15 '18 21:11 krishnarohitreddy

@krishnarohitreddy I think you can do that when you define the http like:

GraphQL::Client::HTTP.new("URL") do
  def connection
    Net::HTTP.new(uri.host, uri.port).tap do |client|
       client.open_timeout = 5
       client.read_timeout = 5
       client.use_ssl = uri.scheme == "https"
     end
   end
end

rubene avatar Jun 14 '19 14:06 rubene

If you want to use all of the Net::HTTP config from GraphQL::Client::HTTP#connection, you can piggyback off of what it normally returns. E.g.

GraphQL::Client::HTTP.new("URL") do
  def connection
    super.tap do |client|
       client.read_timeout = 5
     end
   end
end

nickhoffman avatar Mar 07 '22 02:03 nickhoffman

Though those solutions work. I think the community would be happier in general if the library provides an interface for changing this setting, instead of having to directly set up the underlying Net::Http object: If the library decides to change its implementation details my code will be broken.

But still, thanks for providing a solution for the problem

arbesulo avatar Oct 10 '22 07:10 arbesulo