I tried to fetch data without building widgets and found that the query kept returning results from the cache.
I updated the user's info through RESTFUL POST API, and when I re-fetched the user's data, it uses the cache instead of network data.
class MemberService {
...
Future<List<MemberResponse>> gqlReadMember() async {
var result = await readMember;
List data = result.data?["members"];
return data.map((item) => MemberResponse.fromJson(item)).toList();
}
}
Even with fetchPolicy: FetchPolicy.networkOnly specified, the results are not from the server.
When I used the Query widget with fetchPolicy set to network only, it works as I expected.
I tried to fetch data without building widgets and found that the query kept returning results from the cache. I updated the user's info through RESTFUL POST API, and when I re-fetched the user's data, it uses the cache instead of network data.
My graphql client is defined as below:
Inside my flutter widget, I called a gqlReadMember function to retrieve member data from the server.
I defined gqlReadMember as below, it is defined in a MemberService class, and it calls readMember inside the body.
Even with
fetchPolicy: FetchPolicy.networkOnly
specified, the results are not from the server.When I used the
Query
widget with fetchPolicy set to network only, it works as I expected.e.g.
I am wondering if any mistakes or missed setups are made with my current implementation. Thanks for your support in advanced! 🙏
graphql_flutter: ^5.1.2