Skip to content

Add parse_response extension point to HTTP adapter - #85

Open
wuarmin wants to merge 1 commit into
github-community-projects:masterfrom
wuarmin:parse-response-hook
Open

wuarmin wants to merge 1 commit into
github-community-projects:masterfrom
wuarmin:parse-response-hook

Conversation

@wuarmin

@wuarmin wuarmin commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Hey @rmosolgo,

this PR is just a refactoring and moves the response handling of GraphQL::Client::HTTP#execute into a public parse_response(response) method, an extension point like headers and connection.

Why: Statuses other than 200 and 400 become GraphQL-style errors, so a 503 looks like any other GraphQL error. To handle HTTP statuses yourself, you currently have to copy execute. With the hook, you override just the response handling:

HTTP = GraphQL::Client::HTTP.new("https://example.com/graphql") do
  def parse_response(response)
    return super if response.is_a?(Net::HTTPOK) || response.is_a?(Net::HTTPBadRequest)

    raise MyApp::UpstreamError, "HTTP #{response.code}"
  end
end

No behavior change, unless a subclass already defines its own parse_response. Includes tests and a short section in guides/handling-errors.md.

I would be very grateful for a merge and a release. It would streamline the implementation.

Thanks
Armin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant