Reference · SDK

queryOptions · getOptions · versionsOptions

Next release: this page describes techne-sdk/types, which is not in techne-sdk 0.3.4 yet. With techne-sdk 0.3 today shows the released API.

methodstechne-sdk/connectTanStack Query

The three reads in the form TanStack Query takes, a { queryKey, queryFn } each. Use them with TanStack Query outside the hooks, or with another data library.

The React hooks are these forms passed to useQuery. Each key starts ['techne', …] and ends with the viewer's DID, so one viewer's reads are never another's. A prefix such as ['techne', 'versions'] still names them all.

The three on techne

NameTypeWhat it is
queryOptions(q, opts?){ queryKey, queryFn }Key ['techne', 'query', q, opts, did]. Its queryFn answers the Page of techne.query.
getOptions(uri, opts?){ queryKey, queryFn }Key ['techne', 'record', uri, opts, did]. Its queryFn answers the item of techne.get, or null.
versionsOptions(uri){ queryKey, queryFn }Key ['techne', 'versions', uri, did]. Its queryFn answers techne.versions.

Options left out are {} in the key. The anonymous client's DID is empty, so its keys never meet a signed-in viewer's.

Each form ReadOptions

NameTypeWhat it is
queryKeyreadonly arrayThe cache key, as above.
queryFn() => PromiseRuns the read.
Your own useQuery, and a refresh after a write
Prefetch on a server or before a screen opens

The hooks over them are useRecordQuery, useRecord and useVersions →