const fetchNotifications = useNotificationsQuery({
variables: {
skip: SKIP,
take: TAKE,
},
async onCompleted(data){
let ids:Array<string>=[]
data?.notifications?.forEach((e)=>{
ids.push(e?.id+"")
})
setIds(ids)
readNotifications()
}
});
const readNotifications =()=> usereadNotifications({
variables: { notificationIds: ids},
async onCompleted(data){
console.log("res"+data)
}
})
和 usereadNotifications 来自
export const readNotifications = gql` mutation readNotifications($notificationIds: [String]!) {
readNotifications(notificationIds: $notificationIds)
} `;
export const usereadNotifications = (options?: QueryHookOptions) => (
useMutation(readNotifications, options)
);