Skip to content

Commit dd7e67d

Browse files
committed
fix: actually skip request on skipToken
1 parent 598c869 commit dd7e67d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/index.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@ function createVueQueryProxyDecoration<TRouter extends AnyTRPCRouter>(
8585
const queryFn = computed<QueryFunction>(() => async ({ signal }) => {
8686
const input = toValue(_input)
8787

88-
const output = await trpc.query(joinedPath, input, {
89-
signal,
90-
...trpcOptions,
91-
})
88+
const output =
89+
input === skipToken
90+
? undefined
91+
: await trpc.query(joinedPath, input, {
92+
signal,
93+
...trpcOptions,
94+
})
9295

9396
if (type === 'queries') return { output, input }
9497

@@ -163,6 +166,8 @@ function createVueQueryProxyDecoration<TRouter extends AnyTRPCRouter>(
163166
watch(
164167
inputData,
165168
() => {
169+
if (inputData.value === skipToken) return
170+
166171
subscription.value?.unsubscribe()
167172

168173
subscription.value = trpc.subscription(joinedPath, inputData.value, {

0 commit comments

Comments
 (0)