wobsoriano / trpc-nuxt

End-to-end typesafe APIs in Nuxt applications.
trpc-nuxt.vercel.app
MIT License
687 stars 39 forks source link

feat: getQueryKey helper #131

Closed wobsoriano closed 12 months ago

wobsoriano commented 12 months ago

This PR improves thegetQueryKey helper so that it's able to accept a procedure and return the cache key:

import { getQueryKey } from 'trpc-nuxt/client'

const queryKey = getQueryKey($client.getTodos, undefined)

// Access to the cached value
const { data } = useNuxtData(queryKey)

// Mutate
data.value.push({...})

// Invalidate
await refreshNuxtData(queryKey)

Also some cleanups

vercel[bot] commented 12 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
trpc-nuxt ✅ Ready (Inspect) Visit Preview Dec 7, 2023 3:04am