如何每2秒从apollo-link-state获取数据(客户端数据轮询)

时间:2018-05-07 09:46:08

标签: reactjs graphql apollo react-apollo

我正在尝试使用react和apollo-link-state作为数据存储,仅向客户端发出通知(数据不是来自服务器) 我问的是如何每隔2秒从缓存中获取数据(轮询),数据是@client状态数据,而不是像我说的那样来自服务器。

这是我的查询:

 const GET_NOTIF_LIST = gql`
    {
        notificationsState @client {
        notifications  {
        uid
        title
        message
        type
        position
        autodismiss
          __typename
        }
      }
    }
`;

这是应该仅从缓存中轮询数据的组件:

   render(){
     return (
       <Query query={GET_NOTIF_LIST} >
             {({ loading, error, data }) => {  
                 return (<NotificationSystemComponent  notifications={data.notificationsState.notifications || []} />)
             }}
   
       </Query>
     )
   }

0 个答案:

没有答案
相关问题