Grasp
Public
Showcasesindresorhus/ky #873SourceMarkdown

Add QUERY method support to ky

ky can now issue HTTP QUERY requests, a method that takes a body where GET cannot. The change is four lines, split between the method allow-list and the normalizer that uppercases it.

MERGEDTessera · Jul 30, 2026

Three explanations of the same brief

No jargon, about fifteen seconds

Add QUERY method support to ky

Someone changed how a program works. Before, allowed methods was get, post, put, patch, head, delete. Now it is …and query. The part to watch: QUERY is still a proposed method.

get, post, put, patch, head…before…and queryafter
What changed about allowed methods

31 words · derived from the brief below, no model involved

ky gains a query() helper so callers can send a body with a read-only request.

HTTP QUERY behaves like GET but accepts a request body. Search endpoints want it because a complex filter does not fit comfortably in a URL, and ky rejected it before a request was ever built.

ky keeps an allow-list of HTTP methods. Anything outside it failed at the client, which meant QUERY never reached the server to be rejected on its own terms.

This adds QUERY to that list and exposes ky.query(), matching the shape of the existing helpers. Nothing about body or search-param serialization changed, so a QUERY request is assembled by the same code that assembles a POST.

One new public method

query() joins get, post, put, patch, head, and delete, taking the same options object.

The normalizer is the real edit

normalizeRequestMethod only uppercases methods it recognizes. QUERY had to be added there too, not just to the allow-list.

One array is both type and runtime

requestMethods is the allow-list and the source of the RequestMethod union, so the two cannot drift.

BEFOREky('/search', …)method: 'QUERY'rejected at the clientnot in the allow-listAFTERuppercasedky.query('/search')normalizeRequestMethodsource/utils/normalize.tsfetch(request)body preserved
Where a QUERY call stopped before, and where it goes nowDownload for draw.io

What this brief could not check

  • This brief was written by hand as a design fixture. It is modelled on real work, but no model read a diff to produce it, and its claims should not be relied on.
  • CI output was not read, so nothing here rests on a check result.