You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.
React.useEffect(()=>{constsubscription=requestSubscription<chatUserUpdateSubscription>(environment,{subscription: UserUpdateSubscription,variables: {},updater: (store)=>{constusers=ConnectionHandler.getConnection(store.getRoot(),"chat_users");constupdateRecord=store.getRootField("userUpdate");if(!users||!updateRecord)return;if(updateRecord.getValue("__typename")==="UserAddUpdate"){constedge=ConnectionHandler.createEdge(store,users,updateRecord.getLinkedRecord("user"),"User");ConnectionHandler.insertEdgeAfter(users,edge);}elseif(updateRecord.getValue("__typename")==="UserRemoveUpdate"){// updateRecord should be// RecordProxy<{// readonly __typename: "UserRemoveUpdate";// readonly userId: string;// }// userId should be a stringconstuserId=updateRecord.getValue("userId");if(typeofuserId!=="string")return;ConnectionHandler.deleteNode(users,userId);}},});return()=>subscription.dispose();},[environment]);
Maybe it is possible to correctly infer the type based on the __typename property comparison?
The text was updated successfully, but these errors were encountered:
n1ru4l
changed the title
Distinguish union type via _typename in subscription updater function
Distinguish union type via __typename in subscription updater function
May 18, 2020
Schema:
Subscription:
Maybe it is possible to correctly infer the type based on the
__typename
property comparison?The text was updated successfully, but these errors were encountered: