Closed MagedAlNaamani closed 2 years ago
we need an example for this!
You can use our endpoint https://api.chat.graphql-flutter.dev/graphql
Hi @vincenzopalazzo
Yes I try it with your endpoint but it the same issue keep show loading only.
if you push the example that you try somewhere I can reproduce it, because I'm currently use in production the client and my code works
Hi
Here is the full code exactly.
import 'package:flutter/material.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
class TrackingScreen extends StatefulWidget {
const TrackingScreen({Key? key}) : super(key: key);
@override
State<StatefulWidget> createState() {
return _TrackingScreenState();
}
}
class _TrackingScreenState extends State<TrackingScreen> {
@override
Widget build(BuildContext context) {
final httpLink = HttpLink(
'https://api.chat.graphql-flutter.dev/graphql',
);
final authLink = AuthLink(
getToken: () async => 'Bearer token',
);
var link = authLink.concat(httpLink);
final websocketLink = WebSocketLink(
'wss://api.chat.graphql-flutter.dev/graphql',
config: const SocketClientConfig(
inactivityTimeout: Duration(seconds: 30),
delayBetweenReconnectionAttempts: Duration(seconds: 10),
),
);
link = Link.split(
(request) => request.isSubscription,
websocketLink,
link,
);
final client = ValueNotifier<GraphQLClient>(
GraphQLClient(
cache: GraphQLCache(),
link: link,
),
);
return GraphQLProvider(
client: client,
child: CacheProvider(
child: Subscription(
options: SubscriptionOptions(
document: gql("""subscription ChatCreated {
chatCreated {
id
description
name
}
}"""),
),
builder: (result) => result.isLoading
? const Center(child: Text('Loading...'))
: Center(child: Text(result.data.toString())),
),
),
);
}
}
@vincenzopalazzo
check this screenshot of what is printing in the debug console.
Mh I think you need to change the protocol.
Check how I do this https://github.com/zino-hofmann/graphql-flutter/pull/1204
Hi @vincenzopalazzo
The issue fixed after upgrade to graphql_flutter 5.1.1-beta.4
and add subprotocol to Graphql-transport-ws
.
Coo! :) the beta is not so reckless is it?
I face an issue that my request not reach to backend... Can you help in this?
also the same subscription work in Apollo graphql website.