WatchQuery vs Subscription #1251
Unanswered
EveryPerspective
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am looking for the example of watchquery on the official examples, but only subscription example only exists.
I am testing watchQuery myself, below is the code i wrote. but it doesn't seem like data streaming works properly.
can you guys help me or share watchquery examples?
class TimelineFollowingList extends StatelessWidget {
const TimelineFollowingList({Key? key}) : super(key: key);
@OverRide
Widget build(BuildContext context) {
final watchQuery = WatchQueryOptions(
document: gql(userfollowing()),
variables: {
'search': id,
'start': 0,
'end': 1
},
fetchPolicy: FetchPolicy.networkOnly,
errorPolicy: ErrorPolicy.ignore,
cacheRereadPolicy: CacheRereadPolicy.ignoreAll,
);
return Query(
options: watchQuery,
builder: ((result, {fetchMore, refetch}) {
if (result.hasException) {
return Center(child: Text(result.exception.toString()));
}
if (result.isLoading) {
return const Center(
child: Text('Loading'),
);
}
print('===========watchquery test${result.data}');
}
}
Also, do I need to use susbscription if I need to want to stream data from server? please compare two(WatchQuery vs Subscription) and which one is better?
(if "watchqueryoption" is going to be deprecated somewhere in the future, I will use subscription)?
Belows are what I am think of.
the benifit of watchquery
subscription
Beta Was this translation helpful? Give feedback.
All reactions