Skip to content

Accept only Query Fragments in query templates - #2636

Open
kmcginnes wants to merge 1 commit into
query-fragment-only-templates-4-sparql-fragmentsfrom
query-fragment-only-templates
Open

kmcginnes wants to merge 1 commit into
query-fragment-only-templates-4-sparql-fragmentsfrom
query-fragment-only-templates

Conversation

@kmcginnes

@kmcginnes kmcginnes commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Every query call site now passes Query Fragments, so this narrows the tag to accept only fragments. The type checker now enforces the rule that a value reaches a query only through a fragment constructor. Until now that rule held only by review.

 export function query(
   literals: TemplateStringsArray,
-  ...placeholders: unknown[]
+  ...placeholders: QueryFragment[]
 ): QueryFragment
  • Interpolating a plain string or number into a query template is now a compile error.
  • docs/agents/connectors.md describes the tag, joinFragments, and the raw-query path. It also says toQueryFragment belongs to the fragment modules and the composition helpers, and is never a way to clear the new type error.
  • Tests that interpolated plain values now wrap them in fragments, with the same literal text.

Evidence

After: @ts-expect-error tests in sanitizeQuery.test.ts interpolate a string and a number. Reverting the signature to unknown[] fails the type check on both.

Merge Danger

Door: two-way

Impact: none at runtime. Code that interpolates plain values into query stops compiling, and no such code remains in the repo.

Related


🤖 Written by an AI agent on my behalf.

Layer: 5-fragment-only-placeholders
@kmcginnes
kmcginnes added this pull request to stack #2637 November 18, 2026 20:47

This branch has not been deployed

No deployments
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.

Make query templates accept only Query Fragments

1 participant