Skip to content

Commit

Permalink
fix(mutate): serialize key passed for global mutate function
Browse files Browse the repository at this point in the history
  • Loading branch information
edumudu committed Sep 8, 2022
1 parent 3a1c52e commit d00fd46
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/composables/global-swr-config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { computed, inject, provide, unref, shallowReadonly, toRefs } from 'vue';
import { MaybeRef } from '@vueuse/core';

import { defaultConfig, globalConfigKey } from '@/config';
import { AnyFunction, SWRConfig } from '@/types';
import { mergeConfig } from '@/utils';
import { AnyFunction, Key, SWRConfig } from '@/types';
import { isUndefined, mergeConfig, serializeKey } from '@/utils';
import { useScopeState } from '@/composables/scope-state';

export type MutateOptions = {
optimisticData?: unknown;
Expand All @@ -17,10 +18,11 @@ export const useSWRConfig = () => {
);

const mutate = async <U extends unknown | Promise<unknown> | AnyFunction>(
key: string,
updateFnOrPromise: U,
_key: Key,
updateFnOrPromise?: U,
options: MutateOptions = {},
) => {
const { key } = serializeKey(_key);
const cachedValue = contextConfig.value.cacheProvider.get(key);
const { optimisticData, rollbackOnError } = options;

Expand Down

0 comments on commit d00fd46

Please sign in to comment.