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;