File size: 554 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import { fetchProfile, updateProfile } from '../../data/me-profile';
import { queryClient } from '../query-client';
import type { UserProfile } from '../../data/me-profile';
export const profileQuery = () => ( {
queryKey: [ 'me', 'profile' ],
queryFn: fetchProfile,
} );
export const profileMutation = () => ( {
mutationFn: updateProfile,
onSuccess: ( newData: Partial< UserProfile > ) => {
queryClient.setQueryData( profileQuery().queryKey, ( oldData: UserProfile | undefined ) =>
oldData ? { ...oldData, ...newData } : newData
);
},
} );
|