Reputation: 21
I got a PageView
in the home page with Query
for a list of data, and every time push to another route will causing build
. And the Query
in build
will call backend Api and rerender. How to avoid the query?
Query
widget init in initState
won't work@override
Widget build(BuildContext context) {
return Query(
options: QueryOptions(
document: queryDocument,
),
builder: (QueryResult result, {VoidCallback refetch, FetchMore fetchMore}) {
print('will call backend each push and pop route and the build causing by state changes');
}
);
}
Expect the builder won't be alway call and to reduce the backend query. (I'm new to graphql_flutter and the document is not cover such case.)
Upvotes: 2
Views: 949
Reputation: 21
The issue is resolved in the next beta version https://pub.dev/packages/graphql_flutter/versions/2.1.1-beta.2
See: https://github.com/zino-app/graphql-flutter/issues/412
Upvotes: 0