( mutationFn: (input: TInput) => Promise<TResult>, requestKeys: RequestKey[], )
| 30 | }; |
| 31 | |
| 32 | const useInvalidatingMutation = <TInput, TResult>( |
| 33 | mutationFn: (input: TInput) => Promise<TResult>, |
| 34 | requestKeys: RequestKey[], |
| 35 | ) => { |
| 36 | const queryClient = useQueryClient(); |
| 37 | |
| 38 | return useMutation({ |
| 39 | mutationFn, |
| 40 | onSuccess: () => { |
| 41 | requestKeys.forEach((requestKey) => |
| 42 | queryClient.invalidateQueries({ |
| 43 | queryKey: generateQueryKey(requestKey), |
| 44 | }), |
| 45 | ); |
| 46 | }, |
| 47 | }); |
| 48 | }; |
| 49 | |
| 50 | export const useCreateOAuthClient = () => |
| 51 | useInvalidatingMutation(createOAuthClient, [RequestKey.OAuthClients]); |
no test coverage detected