如何解决为什么即使我回到组件,Apollo 也只被触发一次?
所以基本上我有两个组件(餐厅/一般和餐厅/日程),每个组件都有一个 GRAPQL API CALL。
当我第一次去餐厅/一般时,会调用 graphql,如果我去餐厅/日程表也是如此。
但是,当我从餐厅/日程返回到餐厅/一般时,阿波罗不会对餐厅/一般进行相应的调用,如果我对餐厅/日程也这样做
每次加载组件时触发 API Calls 的方法在 OnInit 内部,Apollo 仍然没有再次调用后端
谁能帮我解决这个问题?
This is image for restaurant/general query
This is image for shedule query
这是我的餐厅通用组件视图:
通用组件
ngOnInit(): void {
this.getGeneralStoreInformation(); }
getGeneralStoreInformation = () => {
this.generalInformation = this.apollo.watchQuery<any>({
query: MerchantRestaurantInfo,variables: {
id: this.merchantId
}
})
.valueChanges
.subscribe((response: any) => {
this.merchantRestaurantName = response.data.merchant.name;
this.merchantRestaurantEmail = response.data.merchant.email;
});
}
这是我的日程组件视图:
ngOnInit(): void {
this.getStoreScheduleInformation();
}
getStoreScheduleInformation(): void {
this.scheduleInformation = this.apollo.watchQuery<any>({
query: StoreSchedules,variables: {
storeIds: this.storeIdSelected !== '' ? [this.storeIdSelected] : this.allStoreIds,merchantIds: [this.merchantId]
}
})
.valueChanges
.subscribe((data: any) => {
this.scheduleData = data.data.storeSchedules.nodes;
this.scheduleDataCopy = this.scheduleData;
})
}
非常感谢您的时间
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。