Documentation claims useSWRMutation key parameter to be "same as mutate's key".
However, useSWRMutation in fact does not accept a filter function as the global mutate does.
As I understand, this means that in order to implement partial keys revalidation when using useSWRMutation hook, one must call the global mutate() API inside an onSuccess callback.
This in turn leads to another issue when trying to build a custom wrapper hook around useSWRMutation: injecting revalidation behavior in options.onSuccess is not possible, because the callback is getting overwritten by one provided in the parameters of the trigger() call.
Please provide clarification for useSWRMutation API in the docs, and explain what is the proper way to revalidate array keys while using mutation hook and knowing only a part of the key.
Documentation claims
useSWRMutationkeyparameter to be "same as mutate's key".However,
useSWRMutationin fact does not accept a filter function as the globalmutatedoes.As I understand, this means that in order to implement partial keys revalidation when using
useSWRMutationhook, one must call the globalmutate()API inside anonSuccesscallback.This in turn leads to another issue when trying to build a custom wrapper hook around
useSWRMutation: injecting revalidation behavior inoptions.onSuccessis not possible, because the callback is getting overwritten by one provided in the parameters of thetrigger()call.Please provide clarification for
useSWRMutationAPI in the docs, and explain what is the proper way to revalidate array keys while using mutation hook and knowing only a part of the key.