v0.41.0
Minor Changes
-
fc1c87e: Add
queryOptionsandmutationOptionsas the canonical Result-to-TanStack adapters.wellcrafted/querynow exposes two lower-level helpers alongsidedefineQuery/defineMutation:queryOptions(input)accepts aqueryKeyplus a Result-returningqueryFnand returns standardQueryObserverOptionswhosequeryFnresolvesOk(data)and throwsErr(error).mutationOptions(input)accepts amutationKeyplus a Result-returningmutationFnand returns standardMutationOptionswith the same Result unwrapping behavior.
These helpers are platform-agnostic: no
QueryClientrequired. They compose cleanly inside framework hooks:import { queryOptions, mutationOptions } from "wellcrafted/query"; const user = createQuery(() => queryOptions({ queryKey: ["user", userId], queryFn: () => services.getUser(userId), }) ); const save = createMutation(() => mutationOptions({ mutationKey: ["saveUser"], mutationFn: (input: SaveUserInput) => services.saveUser(input), }) );
defineQueryanddefineMutationnow compose through these helpers, so there is exactly one canonical conversion path fromResult<TData, TError>to TanStack's throwing contract. The.optionsproduced bydefineQueryanddefineMutationis the same shape returned byqueryOptionsandmutationOptions.Use
queryOptions/mutationOptionswhen options are local to a hook call site. UsedefineQuery/defineMutationwhen you also want imperative helpers (.fetch,.ensure,.execute, callable form) bound to a specificQueryClient.The new helpers share names with TanStack Query's framework-adapter identity helpers (
@tanstack/react-query,@tanstack/svelte-query). This is intentional: Wellcrafted's versions are the Result-aware equivalents. If you need both in one file, alias one on import.