我无法在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();
}
),
);
}
}