Skip to content

feature (minor): Valueless query flags via [QueryName] (Retrofit @QueryName equivalent) #2168

Closed

Description

@glennawatson

Summary

Refit's [Query] always emits key=value. There's no way to emit a valueless query flag — a bare ?filter with no = — which some APIs use for presence-style switches.

Prior art: Retrofit @QueryName

Retrofit has @QueryName: the parameter value becomes the query parameter name with no value. A List/array produces multiple bare flags (?a&b&c). encoded=true disables encoding of the name.

Proposal

Add an equivalent — most naturally a small attribute (e.g. [QueryName]) or an option on [Query] — that renders the parameter's string value as a valueless query segment. Collections render as repeated bare names. Honour the existing query encoding/URI-format settings.

Considerations

  • Interaction with UrlResolutionMode and QueryUriFormatAttribute.
  • Null handling: omit on null (consistent with [Query]).
  • Must be implemented in both the reflection and source-generator paths.
  • Decide attribute-vs-[Query]-option; a separate attribute reads clearer and matches Retrofit.

Acceptance criteria

  • A parameter renders as a bare ?name flag; collections render as repeated names.
  • Works in reflection + generated paths.
  • TUnit tests for scalar and collection cases; README/docs entry.

Pointers

  • Query building: src/Refit/RequestBuilderImplementation.QueryAndHeaders.cs and .Helpers.cs.
  • Attribute examples to mirror: src/Refit/QueryAttribute.cs.
  • Generator: src/InterfaceStubGenerator.Shared/*.
  • Retrofit reference: ~/square/retrofit/retrofit/src/main/java/retrofit2/http/QueryName.java.

Activity

  1. added
    🟢 priority: low
    🔗 area: url-routing
    on Jun 24, 2026
  2. glennawatson commented on Jul 15, 2026

    @glennawatson
    ContributorAuthor

    This is addressed in the Refit 14 beta, now available on NuGet: https://www.nuget.org/packages/Refit/14.0.0-beta.1

    Please give it a try - feedback ahead of the stable 14.0.0 release is very welcome.

    Type-safe REST API clients for .NET, generated from annotated interfaces with build-time source generation, direct request construction, System.Text.Json defaults, and support for trimming and AOT.
  3. github-actions commented on Jul 30, 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.

  4. locked as resolved and limited conversation to collaborators on Jul 30, 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

    Featureup-for-grabs✨ enhancement🔗 area: url-routing🟢 priority: low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions