From 0c6b0e7593598bb9d799e82235d927f1bb6b4ea5 Mon Sep 17 00:00:00 2001 From: Michael Joseph Rosenthal Date: Thu, 11 Mar 2021 19:14:58 -0600 Subject: [PATCH] fix(client): fix rebroadcasting for regular queries --- packages/graphql/lib/src/core/query_manager.dart | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/graphql/lib/src/core/query_manager.dart b/packages/graphql/lib/src/core/query_manager.dart index 9a5133b82..572ab66b3 100644 --- a/packages/graphql/lib/src/core/query_manager.dart +++ b/packages/graphql/lib/src/core/query_manager.dart @@ -123,11 +123,15 @@ class QueryManager { } } - Future query(QueryOptions options) => fetchQuery('0', options); - + Future query(QueryOptions options) async { + final result = await fetchQuery('0', options); + maybeRebroadcastQueries(); + return result; + } + + Future mutate(MutationOptions options) async { final result = await fetchQuery('0', options); - // not sure why query id is '0', may be needs improvements // once the mutation has been process successfully, execute callbacks // before returning the results final mutationCallbacks = MutationCallbackHandler( @@ -142,8 +146,7 @@ class QueryManager { await callback(result); } - /// [fetchQuery] attempts to broadcast from the observable, - /// but now we've called all our side effects. + /// wait until callbacks complete to rebroadcast maybeRebroadcastQueries(); return result;