Skip to content

Commit bf25362

Browse files
authored
docs: show when each page was last updated, and align the README comparison (#277)
* docs: show when each page was last updated, and align the README comparison - Every docs page shows "Last updated", and its TechArticle JSON-LD carries dateModified, both from git. They are off in a shallow clone, like the sitemap dates, which would otherwise date most pages to the oldest commit fetched. - The README comparison table now matches the Comparison page: Kubb is in it, suspense, prefetch and ensureQueryData are rows of their own, and the release line, configuration and CI check are listed. The "hierarchical keys / tags" row is gone, as nothing on the Comparison page backs it. The footnote dates the measured rows and the feature rows separately, and the scope note points non-React users to Orval, Kubb or Hey API. * docs: say which operations get which helpers in the README intro Suspense hooks, queryOptions factories, prefetch and ensureQueryData functions are generated for GET operations; the others get a mutation hook.
1 parent 4b5e800 commit bf25362

4 files changed

Lines changed: 32 additions & 19 deletions

File tree

‎README.md‎

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,30 @@ See the [documentation](https://orqc.7nohe.dev) for [CLI options](https://orqc.7
8080
8181
## How it compares
8282

83-
| | This library | @hey-api tanstack-query plugin | Orval | openapi-react-query |
84-
|---|---|---|---|---|
85-
| `queryOptions` / `infiniteQueryOptions` factories (TanStack v5 pattern) | ✅ | ✅ | ✅ (`getXxxQueryOptions`) | ✅ (`$api.queryOptions`) |
86-
| Ready-to-use hooks (`useQuery` / suspense / infinite variants) | ✅ generated per operation | ❌ (options only) | ✅ | ✅ runtime wrapper (method + path strings) |
87-
| SSR helpers (`prefetchQuery` / `prefetchInfiniteQuery` / `ensureQueryData`) | ✅ | ❌ | Partial (`usePrefetch`) | Not provided (use `queryOptions`) |
88-
| Hierarchical query keys for granular invalidation | ✅ | ✅ (tags) | Partial | Not documented |
89-
| Stable release line | ✅ SemVer | pre-1.0, frequent breaking changes | ✅ | ⚠️ upstream openapi-typescript is in [maintenance mode](https://github.com/openapi-ts/openapi-typescript/issues/2874) |
90-
| MSW mock generation | ✅ (`--mock msw`, fixed values) | ❌ | ✅ (random values with Faker) | ❌ |
91-
| Vue / Solid / Svelte / Angular | ❌ React-focused | ✅ | ✅ | ❌ |
92-
| Generation time, GitHub REST API (1,272 operations)¹ | **0.46 s** | 2.98 s | 4.31 s | 2.10 s |
93-
| Packages added by installing the generator¹ | **9** (2.1 MB) | 51 (10.8 MB) | 89 (101.5 MB) | 35 (20.5 MB) |
94-
| Type errors in the generated code, Stripe / GitHub APIs¹ | **0 / 0** | 274 / 0 | 219 / 1 | 0 / 0 |
95-
96-
¹ Measured on 2026-11-13 on an Apple M2 with Node.js 24 (generation time is the median wall-clock time of the CLI), with 4.0.0-beta.4, `@hey-api/openapi-ts` 0.99.0, Orval 8.46.0 and openapi-typescript 7.13.0 + openapi-react-query 0.5.4. Methods, the other specifications and type-checking times are on the [Benchmarks](https://orqc.7nohe.dev/guides/benchmarks/) page; the scripts are in [`benchmarks/`](./benchmarks). The [Comparison](https://orqc.7nohe.dev/guides/comparison/) page covers Kubb too, and what each tool generates in more detail.
97-
98-
**Scope**: this library is deliberately React-focused — use the hey-api plugin if you need non-React frameworks. Its [MSW mocks](https://orqc.7nohe.dev/guides/mocking/) answer with fixed values taken from the spec and keep no state; use Orval if you want randomly generated mock data.
83+
Built only for React and TanStack Query v5: one command, with no configuration file, gives every GET operation a query hook, a suspense hook, a `queryOptions` factory, a prefetch function and an `ensureQueryData` function, and every other operation a mutation hook. The [Comparison](https://orqc.7nohe.dev/guides/comparison/) page has the details and when another tool fits better.
84+
85+
| | This library | Orval | Kubb | Hey API | openapi-react-query |
86+
|---|---|---|---|---|---|
87+
| Hooks per operation (`useQuery`, `useMutation`) | ✅ always | ✅ | With `hooks: true` | ❌ (documented output is options factories) | Runtime wrapper (`$api.useQuery("get", "/pets")`) |
88+
| Suspense hooks | ✅ always | With `useSuspenseQuery` | With `suspense` | ❌ | ✅ (`$api.useSuspenseQuery`) |
89+
| Prefetch functions | ✅ always | With `usePrefetch` | ❌ | ❌ | ❌ |
90+
| `ensureQueryData` functions | ✅ always | ❌ | ❌ | ❌ | ❌ |
91+
| `queryOptions` factories (TanStack v5 pattern) | ✅ | ✅ (`getXxxQueryOptions`) | ✅ | ✅ | ✅ (`$api.queryOptions`) |
92+
| Query key functions | ✅ | ✅ | ✅ | ✅ | ❌ |
93+
| Check for stale output in CI | ✅ `--check` | ✅ `--outdated` | `--dry-run` shows planned changes | ❌ | ✅ `--check` |
94+
| Configuration | CLI flags | `orval.config.ts` | `kubb.config.ts` | `openapi-ts.config.ts` | CLI flags |
95+
| Release line | ✅ SemVer | ✅ v8 | ✅ v5 | Before 1.0 | ⚠️ [maintenance mode](https://github.com/openapi-ts/openapi-typescript/issues/2874) |
96+
| MSW mocks | ✅ fixed values (`--mock msw`) | ✅ random values (Faker) | ✅ random values (Faker) | In progress | ❌ |
97+
| Vue / Svelte / Solid / Angular | ❌ React only | ✅ | Vue | ✅ | ❌ |
98+
| Generation time, GitHub REST API (1,272 operations)¹ | **0.46 s** | 4.31 s | 2.98 s | 2.98 s | 2.10 s |
99+
| Packages added by installing the generator¹ | **9** (2.1 MB) | 89 (101.5 MB) | 91 (37.4 MB) | 51 (10.8 MB) | 35 (20.5 MB) |
100+
| Type errors in the generated code, Stripe / GitHub APIs¹ | **0 / 0** | 219 / 1 | 0 / 0 | 274 / 0 | 0 / 0 |
101+
102+
The feature rows were checked against each tool's documentation on 2026-11-15 (Orval 8.48.0, Kubb 5.20.1 with `@kubb/plugin-react-query` 5.10.3, `@hey-api/openapi-ts` 0.99.0, openapi-react-query 0.5.4).
103+
104+
¹ Measured on 2026-11-13 on an Apple M2 with Node.js 24 (generation time is the median wall-clock time of the CLI), with 4.0.0-beta.4, Orval 8.46.0, Kubb 5.15.4 with `@kubb/plugin-react-query` 5.9.0, `@hey-api/openapi-ts` 0.99.0 and openapi-typescript 7.13.0 + openapi-react-query 0.5.4. Methods, the other specifications and type-checking times are on the [Benchmarks](https://orqc.7nohe.dev/guides/benchmarks/) page; the scripts are in [`benchmarks/`](./benchmarks).
105+
106+
**Scope**: this library is deliberately React-focused — use Orval, Kubb or Hey API if you need another framework. Its [MSW mocks](https://orqc.7nohe.dev/guides/mocking/) answer with fixed values taken from the spec and keep no state; use Orval or Kubb if you want randomly generated mock data.
99107

100108
**Coming from openapi-typescript / openapi-fetch / openapi-react-query?** See the [migration guide](https://orqc.7nohe.dev/guides/migrating-from-openapi-react-query/).
101109

‎docs/astro.config.mjs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import starlight from "@astrojs/starlight";
44
// @ts-check
55
import { defineConfig } from "astro/config";
66
import starlightLlmsTxt from "starlight-llms-txt";
7-
import { lastModified } from "./src/lastModified.mjs";
7+
import { hasHistory, lastModified } from "./src/lastModified.mjs";
88

99
const site = "https://orqc.7nohe.dev";
1010
const ogUrl = new URL("og.jpg", site).href;
@@ -50,6 +50,9 @@ export default defineConfig({
5050
starlight({
5151
title: "OpenAPI React Query Codegen",
5252
routeMiddleware: "./src/routeData.ts",
53+
// "Last updated" on every page, from git. A shallow clone would date
54+
// most pages to its oldest commit, so the dates are left out there.
55+
lastUpdated: hasHistory,
5356
customCss: [
5457
"@fontsource-variable/ibm-plex-sans/wght.css",
5558
"@fontsource/ibm-plex-mono/400.css",

‎docs/src/lastModified.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ function git(...args) {
2020
// the date of the oldest commit that was fetched. No date is better than a
2121
// wrong one: the build host has to fetch the full history for these to appear
2222
// (on Vercel, the VERCEL_DEEP_CLONE environment variable).
23-
const hasHistory = git("rev-parse", "--is-shallow-repository") === "false";
23+
export const hasHistory =
24+
git("rev-parse", "--is-shallow-repository") === "false";
2425

2526
/**
2627
* When the page at `pathname` was last committed, for the sitemap.

‎docs/src/routeData.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const siteName = "OpenAPI React Query Codegen";
88
* that says which site the page belongs to.
99
*/
1010
export const onRequest = defineRouteMiddleware((context) => {
11-
const { entry, head } = context.locals.starlightRoute;
11+
const { entry, head, lastUpdated } = context.locals.starlightRoute;
1212
const site = context.site;
1313
// The 404 page has no Markdown version and nothing to describe.
1414
if (!site || entry.id === "404") return;
@@ -39,6 +39,7 @@ export const onRequest = defineRouteMiddleware((context) => {
3939
"@id": `${page}#article`,
4040
headline: entry.data.title,
4141
description: entry.data.description,
42+
...(lastUpdated && { dateModified: lastUpdated.toISOString() }),
4243
url: page,
4344
inLanguage: "en",
4445
isPartOf: { "@id": `${home}#website` },

0 commit comments

Comments
 (0)