feat: add QUERY HTTP method support#10802
Merged
jasonsaayman merged 7 commits intoaxios:v1.xfrom Apr 28, 2026
Merged
Conversation
Add support for the HTTP QUERY method as defined in draft-ietf-httpbis-safe-method-w-body. QUERY is a safe, idempotent method like GET but carries a request body, making it suitable for complex queries that cannot be expressed in a URL. Changes: - Add axios.query(url, data, config) and axios.queryForm() shorthands - Register 'query' in default headers initialization - Include 'query' in header cleanup during request dispatch - Add 'QUERY' to Method type in TypeScript definitions (d.ts and d.cts) - Add query/queryForm signatures to Axios class type definitions - Add 'query' to HeadersDefaults interface - Update unit and module typing tests Closes #5465 Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
Contributor
There was a problem hiding this comment.
1 issue found across 7 files
Confidence score: 4/5
- This PR is likely safe to merge with minimal risk, since the only noted issue is moderate-low severity (4/10) and limited to test quality rather than a confirmed runtime bug.
- In
tests/unit/api.test.js, the added checks only assert thatqueryexists as a function, so regressions in actual QUERY request behavior could slip through unnoticed. - The main risk is reduced confidence in API behavior validation, not clear evidence of broken functionality in production code.
- Pay close attention to
tests/unit/api.test.js- expand assertions to cover real QUERY request behavior and outcomes.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/unit/api.test.js">
<violation number="1" location="tests/unit/api.test.js:15">
P2: Custom agent: **Flag AI Slop and Fabricated Changes**
Added tests only verify that `query` exists as a function; they do not validate QUERY request behavior.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Add comprehensive tests for the QUERY HTTP method covering:
- Request method correctness (via mock adapter and real HTTP server)
- Request body support (QUERY accepts a body like POST/PUT/PATCH)
- Custom headers handling
- baseURL configuration with instances
- Content-Type auto-detection (application/json for objects)
- Instance method and defaults merging
- Generic request form axios({ method: 'query' })
- queryForm() multipart/form-data support
- Integration tests against a real HTTP server verifying the QUERY
method string arrives correctly on the wire
Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
Contributor
Author
|
Added comprehensive QUERY method tests in
All 12 tests pass. Thanks for the feedback @jasonsaayman! |
Contributor
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/unit/query.test.js">
<violation number="1" location="tests/unit/query.test.js:176">
P2: queryForm() is only checking the header, so a broken implementation that doesn't actually serialize the body as multipart would still pass.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
jasonsaayman
approved these changes
Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add HTTP QUERY method support (draft-ietf-httpbis-safe-method-w-body). Adds axios.query(url, data, config) and axios.queryForm() shorthands, TypeScript definitions, and tests. Closes #5465. AI-assisted contribution.
Summary by cubic
Adds HTTP
QUERYmethod support toaxiosviaaxios.query(url, data, config)for safe, idempotent read requests that carry a body. Use it for complex query params that don’t fit in the URL.Description
axios.query(url, data, config)(static and instance); data-carrying; noqueryForm().QUERYtoMethod; addquerytoHeadersDefaults; declareAxios.queryinindex.d.ts/index.d.cts.queryin default headers; include in header cleanup and data-carrying method helpers.Docs
/docs/pages/advanced/request-method-aliases.md(en/es/fr/zh) withQUERYusage and draft-status warning. Please publish the docs site.Testing
tests/unit/query.test.jscovering method, body, headers, baseURL, genericaxios({ method: 'query' }), JSON Content-Type, and real HTTP server.QUERYwith body; static/instance helper assertions; CJS/ESM typing helpers now callaxios.query.Semantic version impact
Written for commit 1d76fb9. Summary will update on new commits. Review in cubic