Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 未处理的graphql订阅错误-没有internet连接时_Amazon Web Services_React Native_Graphql_Apollo Client_Aws Appsync - Fatal编程技术网

Amazon web services 未处理的graphql订阅错误-没有internet连接时

Amazon web services 未处理的graphql订阅错误-没有internet连接时,amazon-web-services,react-native,graphql,apollo-client,aws-appsync,Amazon Web Services,React Native,Graphql,Apollo Client,Aws Appsync,使用aws appsync获取实时数据。但是,当我关闭模拟器的internet连接时,会出现如下错误。我做了很多研究,但我做不到。我在等你的帮助。我用谷歌翻译把这篇文章翻译成英语 const client = new AWSAppSyncClient({ url: appSyncConfig.graphqlEndpoint, region: appSyncConfig.region, auth: { type: appSyncConfig.authType, apiK

使用aws appsync获取实时数据。但是,当我关闭模拟器的internet连接时,会出现如下错误。我做了很多研究,但我做不到。我在等你的帮助。我用谷歌翻译把这篇文章翻译成英语

const client = new AWSAppSyncClient({
  url: appSyncConfig.graphqlEndpoint,
  region: appSyncConfig.region,
  auth: {
    type: appSyncConfig.authType,
    apiKey: appSyncConfig.apiKey,
  },
  offlineConfig : {
    callback : ( err ) => {
      if (err) {
        console.warn('error');
     } 
   },
 },DisableOffline: false
},);



export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = { name: "", link: "" ,veri:[],loading:false};

  }

  componentDidMount(){
    client.onConnectionLost = ({ errorCode, ...args }) => { 
  if (errorCode !== 0) { 
     console.warn('error1');
  } 
  else
  {
    console.warn('error2');
  }  
}; 
  }

  render(){
    return(
      <ApolloProvider client={client}>
      <Rehydrated>   
         <Appy />
      </Rehydrated>
    </ApolloProvider>      

    )
  }
}
const client=新的AWSAPSyncClient({
url:appSyncConfig.graphqlEndpoint,
region:appSyncConfig.region,
认证:{
类型:appSyncConfig.authType,
apiKey:appSyncConfig.apiKey,
},
离线配置:{
回调:(错误)=>{
如果(错误){
console.warn('error');
} 
},
},DisableOffline:false
},);
导出默认类应用程序扩展组件{
建造师(道具){
超级(道具);
this.state={name:,link:,veri:[],加载:false};
}
componentDidMount(){
client.onConnectionLost=({errorCode,…args})=>{
如果(错误代码!==0){
控制台。警告('error1');
} 
其他的
{
控制台。警告('error2');
}  
}; 
}
render(){
返回(

您是如何解决此错误的?您是如何解决此错误的?
const ListAppps = gql`query listAppps {
  listAppps {
    items {
      id
      name
      link
      __typename
    }
  }
}`;   

  const OnCreateAppp = gql`subscription onCreateAppp {
    onCreateAppp {
      id
      name
      link
    }
  }`;    


class Appy extends Component {
  componentDidMount() {
    this.props.data.subscribeToMore(
      buildSubscription(OnCreateAppp, ListAppps)
    )
  }

  render() {
    return (
      <View>
        {
          this.props.posts.map((post, index) => (
            <Text key={index}>{JSON.stringify(post.name)}</Text>
          ))
        }
      </View>
    )
  }
}

export default graphql(ListAppps, {
  options: {
    fetchPolicy: 'cache-and-network'
  },
  props: props => ({
    posts: props.data ? props.data.listAppps.items : [],
    data: props.data
  }),
})(Appy)