Repository navigation
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the feature has not already been requested
🚀 Feature Proposal
Add support for the HTTP QUERY method introduced by RFC 10008 as a standard HTTP method in Fastify.
The proposal is to make QUERY a first-class supported HTTP method in Fastify, not only to add a route shorthand. This should include support for route registration with method: 'QUERY', a fastify.query() shorthand, request body parsing, schema validation, content-type parsing, lifecycle hooks, route handling, and TypeScript definitions, as far as applicable to the semantics defined by the RFC.
RFC 10008 defines QUERY as a safe and idempotent HTTP method used to initiate a server-side query. Unlike GET, the query input is sent as request content rather than being encoded entirely in the request URI. Unlike POST, QUERY explicitly communicates safe and idempotent semantics.
Motivation
Some APIs need to support read-only operations with structured, complex, or potentially large query payloads. Today, these cases are commonly implemented with POST, even when the operation does not modify server state, because GET is not suitable for request content and query parameters may be impractical for complex inputs.
Examples include complex search endpoints, filtering APIs, analytics queries, reporting endpoints, and read-only GraphQL-style operations.
Supporting QUERY as a standard HTTP method in Fastify would allow users to model these operations with more accurate HTTP semantics. It would also make Fastify aligned with the standardized HTTP QUERY method while preserving the same developer experience already available for other HTTP methods.
This would let users define safe and idempotent request-content-based query endpoints without relying on POST as a workaround.
Example
fastify.query('/search', {
schema: {
body: {
type: 'object',
properties: {
term: { type: 'string' },
filters: {
type: 'object',
additionalProperties: true
}
},
required: ['term']
}
}
}, async (request, reply) => {
const { term, filters } = request.body
return {
results: []
}
})This should be equivalent to registering the route explicitly with fastify.route():
fastify.route({
method: 'QUERY',
url: '/search',
schema: {
body: {
type: 'object',
properties: {
term: { type: 'string' },
filters: {
type: 'object',
additionalProperties: true
}
},
required: ['term']
}
},
handler: async (request, reply) => {
const { term, filters } = request.body
return {
results: []
}
}
})QUERY routes should support the same Fastify features available for other supported HTTP methods, where applicable:
fastify.addHook('preHandler', async (request, reply) => {
// This hook should run for QUERY routes as it does for other methods.
})
fastify.query('/reports', {
schema: {
body: {
type: 'object',
properties: {
dateFrom: { type: 'string' },
dateTo: { type: 'string' }
},
required: ['dateFrom', 'dateTo']
},
response: {
200: {
type: 'object',
properties: {
data: { type: 'array' }
}
}
}
}
}, async (request, reply) => {
return {
data: []
}
})
Activity
metcoder95 commentedon Jun 22, 2026
+1
Puppo commentedon Jun 22, 2026
Hey all, I worked on this one https://github.com/TheCodePace/fastify-http-query.
If you want, we can include it in the framework.
Eomm commentedon Jun 22, 2026
This is a proposal, so I think we should wait a bit before landing it to be compliant with the spec or we may hit some braking change.
So far, the plugin is the best option
climba03003 commentedon Jun 22, 2026
I agree we should wait until the RFC consolidated before placing to the core.
It is extremely easy to add the method yourself using the
fastify.addHttpMethodat this stage.kalvenschraut commentedon Jul 3, 2026
Unless I am misunderstanding what https://serverfault.com/questions/755654/which-rfcs-should-be-cited-as-internet-standards says the "Proposed Standard" can be treated as locked in and the standard to follow due to officially getted an RFC number and on standards track but definitely dont know the official standards process outside of my present research. Just seemed like the hold up here was out of concern for it changing and sounds like it is highly unlikely to at this point
Specifically
github-actions commentedon Nov 1, 2026
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.