Skip to content

feat: support HTTP QUERY method (RFC 10008) #6807

Closed

Description

@JoaoLucasAl

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.

Reference: https://datatracker.ietf.org/doc/html/rfc10008

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

  1. metcoder95 commented on Jun 22, 2026

    @metcoder95
    Member

    +1

  2. Puppo commented on Jun 22, 2026

    @Puppo
    Member

    Hey all, I worked on this one https://github.com/TheCodePace/fastify-http-query.
    If you want, we can include it in the framework.

  3. Eomm commented on Jun 22, 2026

    @Eomm
    Member

    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

  4. climba03003 commented on Jun 22, 2026

    @climba03003
    Member

    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.addHttpMethod at this stage.

  5. kalvenschraut commented on Jul 3, 2026

    @kalvenschraut
    Contributor

    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

    RFC 7127 is a more recent (2014) update to BCP 9 making it clear that many Proposed Standards are never promoted to Internet Standard despite widespread implementation and high stability. This is in large part due to the higher vetting standards that modern Proposed Standards are subjected to prior to being classified as such. This RFC effectively retracts the prior statement by RFC 2026 that "Implementors should treat Proposed Standards as immature specifications". Never quote that line to anyone.

  6. github-actions commented on Nov 1, 2026

    @github-actions

    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.

  7. locked as resolved and limited conversation to collaborators on Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions