简体   繁体   English

如何在每次构建Query()时禁用graphql_flutter查询后端

[英]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 . 我在首页上有了一个PageView ,其中包含Query以获取数据列表,并且每次推送到另一条路线都会导致build And the Query in build will call backend Api and rerender. buildQuery将调用后端Api并重新渲染。 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.) (我是graphql_flutter的新手,而本文不涉及这种情况。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM