From 9108dcbb1dabfedd0ec006571b5d50fd4c1a801d Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Mon, 31 Oct 2022 22:39:40 -0700 Subject: [PATCH] feat: never cache mutation --- package.json | 1 + pnpm-lock.yaml | 3 ++- src/client/index.ts | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 37b241c..af3281e 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ }, "dependencies": { "h3": "^0.8.5", + "nanoid": "^4.0.0", "ohash": "^0.1.5", "ufo": "^0.8.6" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 14bf2fb..c901964 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,6 +12,7 @@ importers: concurrently: ^7.5.0 eslint: ^8.25.0 h3: ^0.8.5 + nanoid: ^4.0.0 nuxt: 3.0.0-rc.12 ohash: ^0.1.5 pnpm: ^7.14.1 @@ -20,6 +21,7 @@ importers: ufo: ^0.8.6 dependencies: h3: 0.8.6 + nanoid: 4.0.0 ohash: 0.1.5 ufo: 0.8.6 devDependencies: @@ -6706,7 +6708,6 @@ packages: resolution: {integrity: sha512-IgBP8piMxe/gf73RTQx7hmnhwz0aaEXYakvqZyE302IXW3HyVNhdNGC+O2MwMAVhLEnvXlvKtGbtJf6wvHihCg==} engines: {node: ^14 || ^16 || >=18} hasBin: true - dev: true /natural-compare/1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} diff --git a/src/client/index.ts b/src/client/index.ts index 122ac16..7f57507 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -6,6 +6,7 @@ import type { import { createFlatProxy, createRecursiveProxy } from '@trpc/server/shared' import { hash } from 'ohash' import { getCurrentInstance, onScopeDispose } from 'vue' +import { nanoid } from 'nanoid' import type { DecoratedProcedureRecord } from './types' // @ts-expect-error: Nuxt auto-imports import { useAsyncData, useState } from '#imports' @@ -33,7 +34,7 @@ function createNuxtProxyDecoration(name: string, clie const [input, otherOptions] = args - const queryKey = getQueryKey(path, input) + const queryKey = lastArg === 'mutate' ? nanoid() : getQueryKey(path, input) const { trpc, ...asyncDataOptions } = otherOptions || {} as any