Previously, I was running a mutation somewhat like this:
export const useEditLocationName = () => {
const [editFavoriteLocationName] = useEditFavoriteLocationNameMutation({
refetchQueries: [{ query: GetMyFavouritePlacesDocument}],
awaitRefetchQueries: true,
onCompleted: () => {
Alert.alert('Name');
},
onError: () => {
Alert.alert('Oops');
},
});
const editLocationName = async (
favouritePlaceId: number,
customisedName: string,
) => {
editFavoriteLocationName({
variables: {
id: favouritePlaceId,
label: customisedName
},
});
return null;
};
return editLocationName;
};
Every time I run this mutation, the results of the useGetMyFavouritePlacesQuery
i.e the GetMyFavouritePlacesDocument
got updated automatically (wherever this query was being used). This worked perfectly then there were no parameters needed for the useGetMyFavouritePlacesQuery
. However, now that there are some changes in the api, I need to pass an id
to the query in order for it return results. How can I do so?
I cannot pass variables directly to the GetMyFavouritePlacesDocument
and I can also not use the hook here. How else can I efficiently refetch data every time I run this mutation?