query icon indicating copy to clipboard operation
query copied to clipboard

feat(query-core): make `MutateFunction` optional undefinable-variables

Open unnoq opened this issue 9 months ago • 3 comments

Old Behavior:
.mutate, .mutateAsync, ... allowed omitting the variables parameter only when its type was exactly void.

However, in TypeScript, when using union types like unknown | void, the void portion is ignored and treated as unknown, which still requires that variables be provided.

New Behavior:
.mutate, .mutateAsync, ... now allow omitting the variables parameter when its type can be undefined.

This change significantly broadens the optional types, supporting cases such as unknown, any, undefined | ..., void | ..., ...

Another benefit of the new approach is that, for popular schema libraries like Zod and Valibot, it is easier to define an undefinable schema than a void-able one.

unnoq avatar Mar 03 '25 03:03 unnoq

bump

yacobmole avatar Mar 03 '25 05:03 yacobmole

View your CI Pipeline Execution ↗ for commit 01b77b48d8f9729d1acbe81bea63834b4a66a88a.

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ❌ Failed 2m 55s View ↗
nx run-many --target=build --exclude=examples/*... ❌ Failed 1m 15s View ↗

☁️ Nx Cloud last updated this comment at 2025-03-05 14:47:53 UTC

nx-cloud[bot] avatar Mar 05 '25 14:03 nx-cloud[bot]

there are type errors now in other adapters

TkDodo avatar Mar 05 '25 14:03 TkDodo