如何在graphql config flutter中关闭WebSocket?

6l7fqoea  于 2023-11-19  发布在  Flutter
关注(0)|答案(1)|浏览(93)
class GraphqlConfig {
 final serverLink = Link.split(
      (request) => request.isSubscription,
      WebSocketLink(
        "mylink"
      ),
      HttpLink("mylink",
          defaultHeaders: <String, String>{
          
          }));

  initClient() {
    ValueNotifier<GraphQLClient> client = ValueNotifier(
      GraphQLClient(
        link: serverLink,
        cache: GraphQLCache(),
      ),
    );
    
return client;
  }

 GraphQLClient clientToQuery() {
    return GraphQLClient(
      cache: GraphQLCache(),
      link: serverLink,
    );
  }
}

字符串
我得到了以下异常

DOMException: Failed to execute 'close' on 'WebSocket': The code must be either 1000, or between 3000 and 4999. 1001 is neither.

h79rfbju

h79rfbju1#

必须调用

client.dispose();

字符串

websocketLink.dispose();

相关问题