feat: add support for the HTTP QUERY method (RFC 10008)#896
Conversation
Generate query/query! client helpers (carrying a request body, like
post) and extend the Tesla.Env method type with :query.
Adapter support: hackney, gun, and mint pass QUERY through already;
finch now receives the method as an uppercase string, since Finch
rejects unknown method atoms (it normalizes atom methods to strings
internally, so this is behavior-identical for the other methods).
ibrowse crashes its connection process on unknown method atoms, so its
adapter rejects QUERY upfront with
{:error, :method_not_supported_by_adapter}. httpc passes through its
own {:error, :invalid_method}, so QUERY starts working there
automatically once OTP adds support for it.
Document the adapter support matrix in the adapter guide, the Httpc
and Ibrowse moduledocs, and the general cheatsheet.
There was a problem hiding this comment.
Pull request overview
Adds first-class support for the HTTP QUERY method (RFC 10008) across Tesla’s generated client helpers, environment typing, adapter behavior, and documentation, with adapter-specific handling where underlying clients reject unknown methods.
Changes:
- Extend
Tesla.Env.method()andTesla.Builder’s generated helpers to include:query/query/query!(with request-body support). - Ensure Finch can send
QUERYby passing an uppercase string method to Finch, and add a shared adapter test case for QUERY where supported. - Document adapter-level method support and add explicit error behavior for adapters that cannot support QUERY (
ibrowse,httpc).
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/tesla/builder_test.exs | Verifies query/query! functions are generated and included in verb lists. |
| test/tesla/adapter/mint_test.exs | Enables shared QUERY adapter test case for Mint. |
| test/tesla/adapter/hackney_test.exs | Enables shared QUERY adapter test case for Hackney. |
| test/tesla/adapter/gun_test.exs | Enables shared QUERY adapter test case for Gun. |
| test/tesla/adapter/finch_test.exs | Enables shared QUERY adapter test case for Finch. |
| test/tesla/adapter/ibrowse_test.exs | Adds explicit test asserting ibrowse adapter rejects QUERY. |
| test/tesla/adapter/httpc_test.exs | Adds explicit test asserting :httpc returns :invalid_method for QUERY (version-dependent concern noted). |
| test/tesla_test.exs | Adds a shortcut-function test for SimpleClient.query/2. |
| test/support/adapter_case/query.ex | Introduces shared adapter test case for sending QUERY over the wire. |
| lib/tesla/env.ex | Extends method type to include :query. |
| lib/tesla/builder.ex | Adds query to verb generation and documents the QUERY vs :query option naming collision. |
| lib/tesla/adapter/finch.ex | Uses shared format_method/1 to send method as uppercase string to Finch. |
| lib/tesla/adapter/ibrowse.ex | Rejects :query upfront to prevent ibrowse connection-process crashes. |
| lib/tesla/adapter/httpc.ex | Documents QUERY as unsupported by :httpc (wording consistency concern noted). |
| guides/explanations/3.adapter.md | Documents per-adapter QUERY support and failure modes. |
| guides/cheatsheets/general.cheatmd | Adds Tesla.query/2 example and notes adapter limitations (wording consistency concern noted). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Reword the httpc adapter note and the cheatsheet to make QUERY support explicitly OTP-version dependent, match the ibrowse guard on Tesla.Env instead of any map, and make the httpc QUERY test accept a successful response so CI stays green on OTP versions that add QUERY support.
|
@hodak thank you so much! This starts to become a crazy situation with supported features 😭 Also, could you try to make CI to be green/ 🙏🏻 |
|
The CI failures are unrelated to this PR. The test jobs die in the setup step - Hex crashes while Mix loads the dependency graph, before any test runs: This is hexpm/hex#1197: Hex 2.5.0 (published June 29) embeds compiled PCRE2 regex literals in its beam files, restored at runtime via The issue is fixed upstream but not yet released (latest release is still v2.5.0). Until a fixed Hex ships, CI could pin the previous version in the install step: mix local.hex 2.4.2 --force |
Generate query/query! client helpers (carrying a request body, like post) and extend the Tesla.Env method type with :query.
Adapter support:
hackney,gun, andmintpassQUERYthrough already;finchnow receives the method as an uppercase string, since Finch rejects unknown method atoms (it normalizes atom methods to strings internally, so this is behavior-identical for the other methods).ibrowsecrashes its connection process on unknown method atoms, so its adapter rejectsQUERYupfront with{:error, :method_not_supported_by_adapter}.httpcpasses through its own{:error, :invalid_method}, soQUERYstarts working there automatically once OTP adds support for it.