2017-09-16 39 views
0

後,我送取查詢到graphql服務器porps,服務器端返回這樣graphql response我怎樣才能從組件響應訪問錯誤與阿波羅客戶

錯誤,但作出反應成分在他們的道具不顯示錯誤。 component props

我想根據錯誤代碼控制組件如何運行操作。 例如,如果組件不提取任何數據,則會運行mustation動作。然後我想根據失敗或成功再次控制它。

class Room extends React.PureComponent { 
    render() { 
    if (this.props.data.loading) { 
     return (<div>Loading</div>) 
    } 
    if (this.props.errors.code == "bad_request") { 
     //redirect to form 
    } 
    if (this.props.errors.code == "not_found") { 
     // run mutaion query 
    } 

    return (
     <div> 
     Room name is {room.length} 
     </div> 
    ) 
    } 
} 

是否有人知道如何訪問響應值或任何其他最好的錯誤處理?

回答