From 3245e27e0b356915d9c30543d1152ff39ba02501 Mon Sep 17 00:00:00 2001 From: Brian Blanchard Date: Thu, 11 Mar 2021 13:40:26 -0700 Subject: [PATCH] fix(client): fix rebroadcasting for regular queries --- packages/graphql/lib/src/core/query_manager.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/graphql/lib/src/core/query_manager.dart b/packages/graphql/lib/src/core/query_manager.dart index 9e94b5dd2..2eb1537c2 100644 --- a/packages/graphql/lib/src/core/query_manager.dart +++ b/packages/graphql/lib/src/core/query_manager.dart @@ -124,11 +124,16 @@ 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( @@ -143,8 +148,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;