亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

未捕獲的不變違規:存儲錯誤

未捕獲的不變違規:存儲錯誤

Go
小怪獸愛吃肉 2022-07-11 16:03:13
我正在嘗試使用用 Go 編寫的 graphql api 編寫 HackerNews 克隆,并將 graph-gophers 包作為后端,以及使用 apollo graphql-client 作為前端的 Vuejs 應用程序。相關 Github Repos后端 Frontend。我最近實現了訂閱功能,它似乎確實有效,但是每當我對鏈接進行投票時,我都會在 javascript 控制臺中收到一個令人討厭的錯誤,其全文如下。Observable.js?5234:65 Uncaught Invariant Violation: Store error: the application attempted to write an object with no provided id but the store already contains an id of Link:10 for this object. The selectionSet that was trying to be written is:{"kind":"Field","name":{"kind":"Name","value":"link"},"arguments":[],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"votes"},"arguments":[],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"},"arguments":[],"directives":[]},{"kind":"Field","name":{"kind":"Name","value":"user"},"arguments":[],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"},"arguments":[],"directives":[]},{"kind":"Field","name":{"kind":"Name","value":"__typename"}}]}},{"kind":"Field","name":{"kind":"Name","value":"__typename"}}]}},{"kind":"Field","name":{"kind":"Name","value":"__typename"}}]}}    at new InvariantError (webpack-internal:///./node_modules/ts-invariant/lib/invariant.esm.js:16:28)    at invariant (webpack-internal:///./node_modules/ts-invariant/lib/invariant.esm.js:28:15)    at StoreWriter.writeFieldToStore (webpack-internal:///./node_modules/apollo-cache-inmemory/lib/bundle.esm.js:680:166)    at eval (webpack-internal:///./node_modules/apollo-cache-inmemory/lib/bundle.esm.js:576:27)我已經進行了足夠多的調試以確認我嘗試添加到商店的任何內容都沒有丟失任何 ID。我不確定我在這里缺少什么導致此錯誤。一切似乎都有效,但我想知道為什么這個錯誤不斷被拋出。
查看完整描述

1 回答

?
長風秋雁

TA貢獻1757條經驗 獲得超7個贊

我最終弄清楚了這一點。錯誤的原因是在更新商店時發生 upvote 時,我一直專注于 graphql 模式中的投票訂閱,而問題實際上是 upvote 突變。作為架構的一部分返回的鏈接缺少 id。



查看完整回答
反對 回復 2022-07-11
  • 1 回答
  • 0 關注
  • 180 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號