useRecordQuery(query, options?)
One page of a query, as a React read. data is its items, typed by the query. useRecordQuery(Place.query(…)) answers places.
Use it inside <TechneProvider>. It is TanStack Query underneath. It caches, refetches on focus, and shares your app's QueryClient when there is one. Without one it keeps its own.
Parameters
| Name | Type | What it is |
|---|---|---|
queryrequired | Query<T> | A pub.techne.draft.query, usually from a type's helper, e.g. Place.query({ text: { matches: 'cafe' } }). It types the items. |
options.params | { [name]: string } | The query's $param values, e.g. { here: '40.0150,-105.2705' }. |
options.include | 'valid' | 'all' | 'valid' (the default) answers only valid items. 'all' adds pending and invalid ones, with their problems. |
options.limit | number | The page size. It defaults to the query's limit, else the platform's 50. |
Also cursor (the previous page's), count: true (the page gains count and capped), and enabled: false to hold the read.
Returns TanStack's query result, with the SDK's items
| Name | Type | What it is |
|---|---|---|
data | ValidItem<T>[] | undefined | The page's items, in the query's order. undefined until the first answer. With include: 'all', Item<T>[]. |
page | Page<T> | undefined | The whole page. It has items, cursor for the next one, and count and capped when asked. |
isPending | boolean | True until there is data. |
error | Error | null | Why the read failed, if it did. |
refetch | () => Promise | Read again now. |
And the rest of TanStack's useQuery result (isLoading, isFetching, status, …). Its key starts ['techne', 'query', …] and ends with the viewer's DID, so invalidateQueries({ queryKey: ['techne'] }) refreshes every Techne read.
Each item
uri | Uri<T> | The record's address. |
cid | string | The version's content hash. |
record | T | The record itself, e.g. a Place. |
verdict | 'valid' | 'pending' | 'invalid' | The SDK's own check of the record. Always 'valid' unless you ask for 'all'. |
problems | string[] | Why it is not valid, or what it waits for. Empty when valid. |
curated | boolean | A live curated record, composed from people's versions. |
byline | Byline | null | Whose version of a curated record speaks first, and where each field came from. |
record is a Place. record.name and record.kind are typed from its lexicon.
useRecordQuery is useQuery(techne.queryOptions(query, options)), with data the page's items.
Calls pub.techne.draft.query.listRecords → once for each page