Skip to content

Commit

Permalink
fix/#519: 리뷰요약 캐시 무효화 쿼리키 수정 (#520)
Browse files Browse the repository at this point in the history
  • Loading branch information
HyeryongChoi authored Oct 19, 2023
1 parent b7d4558 commit 9a433a1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions frontend/src/hooks/query/review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { FOOD_QUERY_KEY } from './food';
const QUERY_KEY = {
reviewItem: 'reviewItem',
reviewList: (petFoodId: string) => ['reviewList', petFoodId, location.search],
reviewSummary: 'reviewSummary',
reviewSummary: (petFoodId: string) => ['reviewSummary', petFoodId],
reviewListMeta: 'reviewListMeta',
};

Expand Down Expand Up @@ -62,7 +62,7 @@ export const useAddReviewMutation = () => {
mutationFn: postReview,
onSuccess: (_, { petFoodId }) => {
queryClient.invalidateQueries(QUERY_KEY.reviewList(petFoodId));
queryClient.invalidateQueries([QUERY_KEY.reviewSummary]);
queryClient.invalidateQueries(QUERY_KEY.reviewSummary(petFoodId));
queryClient.invalidateQueries(FOOD_QUERY_KEY.foodDetail(petFoodId));

alert('리뷰 작성이 완료되었습니다.');
Expand All @@ -82,7 +82,7 @@ export const useEditReviewMutation = () => {
mutationFn: putReview,
onSuccess: (_, { petFoodId }) => {
queryClient.invalidateQueries(QUERY_KEY.reviewList(petFoodId));
queryClient.invalidateQueries([QUERY_KEY.reviewSummary]);
queryClient.invalidateQueries(QUERY_KEY.reviewSummary(petFoodId));
queryClient.invalidateQueries(FOOD_QUERY_KEY.foodDetail(petFoodId));

alert('리뷰 수정이 완료되었습니다.');
Expand All @@ -101,7 +101,7 @@ export const useRemoveReviewMutation = () => {
mutationFn: deleteReview,
onSuccess: (_, { petFoodId }) => {
queryClient.invalidateQueries(QUERY_KEY.reviewList(petFoodId));
queryClient.invalidateQueries([QUERY_KEY.reviewSummary]);
queryClient.invalidateQueries(QUERY_KEY.reviewSummary(petFoodId));
queryClient.invalidateQueries(FOOD_QUERY_KEY.foodDetail(petFoodId));
},
});
Expand All @@ -111,7 +111,7 @@ export const useRemoveReviewMutation = () => {

export const useReviewSummaryQuery = (payload: Parameter<typeof getReviewSummary>) => {
const { data, ...restQuery } = useQuery({
queryKey: [QUERY_KEY.reviewSummary],
queryKey: QUERY_KEY.reviewSummary(payload.petFoodId),
queryFn: () => getReviewSummary(payload),
});

Expand Down

0 comments on commit 9a433a1

Please sign in to comment.