//from
const callback = useCallback((state)=>{ setState(state.value)}, [state.value])
こちらはHow to update the Apollo Client’s cache after a mutationを意訳し、さらにapolloClientの仕様書での文章を読んでりかいしたことです。 英語読める方はリンク先、仕様書を見ることをお勧めします
subscribeでupdate関数内で更新したオブジェクトを返すとcache側で識別できないのでエラーになっている
Observable.js?a7b2:63 Uncaught Error: Store error: the application attempted to write an object with no provided typename but the store already contains an object with typename of MessageConnection for the object of id $ROOT_QUERY.messages({"messageThreadId":"04140231-6c68-4396-bd5b-58c5fece5e51"}). The selectionSet that was trying to be written is:
JavaScript問題集に問題を追加しました。
問370
a
という変数に{}
かkeyがあるかどうか評価してください
add fetchPolicy="cache-and-network"
を追加
const Noti = () => (
<Query query={unreadMessagesQuery} fetchPolicy="cache-and-network">
{({ data, loading, error }) => {
if(loading) return <LoadView />;
if (error) return ;
In the message read function, I had to update "already read" for the number of messages that have been made in the message details page. Certainly I want to be able to use Batch and update at one time, I can't find the way right now, so I feel better
メッセージの既読機能で、メッセージ画面詳細で任意の数だけ行われているメッセージ分の「既読」更新をしなければならなかった. 確かにBatchをつかって、1回で更新できたらいいけど
1.Uncaught Error: Could not find "client" in the context or passed in as a prop. Wrap the root component in an <ApolloProvider>
, or pass an ApolloClient instance in via props.
contextの中にclientが見つからないか、propsとして渡ってきてません。ApolloProviderの中の root componentをラップするか、propsをとおしてApolloClient instanceを渡してください
For Example, you see like this below code. It's occur Error.