无法使用flutter在graphQL中使用订阅

时间:2019-05-30 21:11:49

标签: flutter graphql

我无法在flutter中集成graphQL订阅。 变异和查询对我来说很好用,但订阅时出现错误。

它给我一个例外: 此链接不支持订阅。

class _GameState extends State<Game> {

  static final  HttpLink httpLink = HttpLink(
    uri:
    'http://staginggraphql-xxxxxxxx/graphql',
    headers: <String, String>{
      'x-token': centralstate.GraphQLToken,
    },
  );

  ValueNotifier<GraphQLClient> client = ValueNotifier(
    GraphQLClient(
        cache: InMemoryCache(), link: httpLink as Link),
  );


  @override
  Widget build(BuildContext context) {


              return GraphQLProvider(
                client: client,
                child: Subscription(
                    operationName,
                    subscription,

                    builder: ({
                      bool loading,
                      dynamic payload,
                      dynamic error,
                    }) {
                      if (payload != null) {
                        return Text(payload['leagueGameStatusUpdate']['appID']);
                      } else if(error!=null){
                        return Text('$error',style: TextStyle(fontSize: 13),);
                      }
                      return Container();
                    }
                ),
              );

  }
}

0 个答案:

没有答案