Joe Deng
Joe Deng

Reputation: 21

How to disable graphql_flutter query backend every time build Query()

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?

@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

Answers (1)

Related Questions