From e323a4d58abea8a8d9f472b4b004b61708cb1e8c Mon Sep 17 00:00:00 2001 From: Maina Wycliffe Date: Mon, 14 Oct 2019 02:41:55 +0300 Subject: [PATCH] feat: attempt to call mutation callbacks from mutation method --- .../graphql/lib/src/core/query_manager.dart | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/graphql/lib/src/core/query_manager.dart b/packages/graphql/lib/src/core/query_manager.dart index c76c22938..0cee710fd 100644 --- a/packages/graphql/lib/src/core/query_manager.dart +++ b/packages/graphql/lib/src/core/query_manager.dart @@ -51,7 +51,24 @@ class QueryManager { } Future mutate(MutationOptions options) { - return fetchQuery('0', options); + return fetchQuery('0', options).then((result) async { + // 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 = MutationCallbacks( + cache: cache, + options: options, + queryId: '0', + ); + + final callbacks = mutationCallbacks.callbacks; + + for (final callback in callbacks) { + await callback(result); + } + + return result; + }); } Future fetchQuery(