Skip to content

feat: add QUERY HTTP method support#10802

Merged
jasonsaayman merged 7 commits intoaxios:v1.xfrom
pierluigilenoci:feat/query-http-method
Apr 28, 2026
Merged

feat: add QUERY HTTP method support#10802
jasonsaayman merged 7 commits intoaxios:v1.xfrom
pierluigilenoci:feat/query-http-method

Conversation

@pierluigilenoci
Copy link
Copy Markdown
Contributor

@pierluigilenoci pierluigilenoci commented Apr 24, 2026

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 QUERY method support to axios via axios.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

  • New alias: axios.query(url, data, config) (static and instance); data-carrying; no queryForm().
  • Types: add QUERY to Method; add query to HeadersDefaults; declare Axios.query in index.d.ts/index.d.cts.
  • Core: register query in default headers; include in header cleanup and data-carrying method helpers.

Docs

  • Updated /docs/pages/advanced/request-method-aliases.md (en/es/fr/zh) with QUERY usage and draft-status warning. Please publish the docs site.

Testing

  • Added tests/unit/query.test.js covering method, body, headers, baseURL, generic axios({ method: 'query' }), JSON Content-Type, and real HTTP server.
  • Updated adapter and API tests: fetch adapter sends QUERY with body; static/instance helper assertions; CJS/ESM typing helpers now call axios.query.

Semantic version impact

  • Minor feature; no breaking changes.

Written for commit 1d76fb9. Summary will update on new commits. Review in cubic

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>
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 that query exists 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.

Comment thread tests/unit/api.test.js
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>
@pierluigilenoci
Copy link
Copy Markdown
Contributor Author

Added comprehensive QUERY method tests in tests/unit/query.test.js (12 tests) covering:

  • Request method correctness — verifies config.method is 'query' via mock adapter
  • Request body support — QUERY accepts a body (like POST/PUT/PATCH), validated both via adapter and real HTTP server
  • Custom headers — confirms custom headers propagate correctly
  • baseURL configuration — works with axios.create({ baseURL }) instances
  • Content-Type auto-detection — sets application/json for object payloads
  • Instance defaults merging — instance headers merge with per-request headers
  • Generic request formaxios({ method: 'query', data }) works
  • queryForm() — sets multipart/form-data Content-Type
  • Integration tests — 3 tests against a real HTTP server verifying the QUERY method string arrives on the wire with correct body, headers, and URL path

All 12 tests pass. Thanks for the feedback @jasonsaayman!

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/unit/query.test.js Outdated
@jasonsaayman jasonsaayman merged commit f39203d into axios:v1.x Apr 28, 2026
29 of 30 checks passed
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.

Add the QUERY HTTP method

2 participants