Skip to content

Commit b36330e

Browse files
committed
Revert "fix: workaround for cannot pass function to module config: nuxt/nuxt#20933"
This reverts commit 6f7dfce.
1 parent 6f7dfce commit b36330e

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

packages/vue-query-nuxt/src/runtime/plugin.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { DehydratedState, DehydrateOptions } from "@tanstack/vue-query"
1+
import type { DehydratedState } from "@tanstack/vue-query"
22
import { QueryClient, VueQueryPlugin, dehydrate, hydrate } from "@tanstack/vue-query"
3-
import { getVueQueryOptions, dehydrateOptionKeys } from "./utils"
3+
import { getVueQueryOptions } from "./utils"
44
import { pluginHook } from "#build/internal.vue-query-plugin-hook"
55
import { defineNuxtPlugin, useRuntimeConfig, useState } from "#imports"
66

@@ -16,15 +16,7 @@ export default defineNuxtPlugin((nuxt) => {
1616

1717
if (import.meta.server) {
1818
nuxt.hooks.hook("app:rendered", () => {
19-
vueQueryState.value = dehydrate(queryClient, dehydrateOptionKeys.reduce<DehydrateOptions>((newDehydrateOptions, key) => {
20-
if (dehydrateOptions[key] !== undefined) {
21-
// https://stackoverflow.com/questions/64408632/typescript-inconsistent-check-for-undefined-why-do-i-need-an-exclamation-poin
22-
// https://stackoverflow.com/questions/60077761/typescript-null-check-doesnt-work-inside-array-map-function/60077855#60077855
23-
const narrowedValue = dehydrateOptions[key]
24-
newDehydrateOptions[key] = () => narrowedValue
25-
}
26-
return newDehydrateOptions
27-
}, {}))
19+
vueQueryState.value = dehydrate(queryClient, dehydrateOptions)
2820
})
2921
}
3022

packages/vue-query-nuxt/src/runtime/utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ const composables = [
1515
] as const
1616

1717
type VueQueryComposables = typeof composables
18-
export const dehydrateOptionKeys = ['shouldDehydrateMutation', 'shouldDehydrateQuery', 'shouldRedactErrors'] as Array<keyof DehydrateOptions>;
1918
export interface ModuleOptions {
2019
stateKey: string
2120
autoImports: VueQueryComposables | false
2221
queryClientOptions: QueryClientConfig | undefined
2322
vueQueryPluginOptions: VueQueryPluginOptions,
24-
dehydrateOptions: { [P in typeof dehydrateOptionKeys[number]]?: boolean }
23+
dehydrateOptions: DehydrateOptions
2524
}
2625

2726
export const defaults: ModuleOptions = {

0 commit comments

Comments
 (0)