#vue.js #graphql #apollo #vue-apollo #graphql-subscriptions
#vue.js #graphql #apollo #vue-apollo #graphql-подписки
Вопрос:
cartProducts: {
query: GET_CART_PRODUCTS,
loadingKey: "loading",
subscribeToMore: {
document: ON_TRANSACTION_CHANGED,
updateQuery(previousResult: any, { subscriptionData }: any) {
const oldTransactions = previousResult.cartProducts.items;
const newTransaction = subscriptionData.data.onTransactionChanged;
const concatItems = [...oldTransactions, newTransaction];
console.log("concatItems:", concatItems);
return {
cartProducts: {
items: concatItems,
__typename: "PaginatedTransaction",
},
__typename: "PaginatedTransaction",
};
},
variables() {
return {
profileId: this.profile.profileId,
};
},
skip() {
return !this.profile?.profileId;
},
},
},
concatItems
переменная содержит правильные данные, но если я удаляю loadingKey
и пытаюсь войти cartProducts
в систему после выполнения вызова подписки, она не обновляется. Что я делаю не так? Заранее спасибо! Дайте мне знать, если вам понадобится дополнительная информация о моей настройке, чтобы понять суть дела.