From 7472bb9102b22b0652f6df53d6bcea66592f8aa0 Mon Sep 17 00:00:00 2001 From: micimize Date: Mon, 26 Oct 2020 10:12:52 -0500 Subject: [PATCH] fix(client): skip cache writes on null data, thus fixing #405 --- packages/graphql/lib/src/core/_query_write_handling.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/graphql/lib/src/core/_query_write_handling.dart b/packages/graphql/lib/src/core/_query_write_handling.dart index 314ee100e..a6a878a59 100644 --- a/packages/graphql/lib/src/core/_query_write_handling.dart +++ b/packages/graphql/lib/src/core/_query_write_handling.dart @@ -49,14 +49,18 @@ extension InternalQueryWriteHandling on QueryManager { /// Part of [InternalQueryWriteHandling], and not exposed outside the /// library. /// + /// If we have no data, we skip caching, thus taking [ErrorPolicy.none] + /// into account + /// /// networked wrapper for [_writeQueryOrSetExceptionOnQueryResult] + /// NOTE: mapFetchResultToQueryResult must be called beforehand bool attemptCacheWriteFromResponse( FetchPolicy fetchPolicy, Request request, Response response, QueryResult queryResult, ) => - (fetchPolicy == FetchPolicy.noCache || response.data == null) + (fetchPolicy == FetchPolicy.noCache || queryResult.data == null) ? false : _writeQueryOrSetExceptionOnQueryResult( request,