Skip to content

Commit

Permalink
fix(client): fix rebroadcasting for regular queries
Browse files Browse the repository at this point in the history
  • Loading branch information
micimize authored Mar 12, 2021
1 parent ea2febd commit 0c6b0e7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/graphql/lib/src/core/query_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,15 @@ class QueryManager {
}
}

Future<QueryResult> query(QueryOptions options) => fetchQuery('0', options);

Future<QueryResult> query(QueryOptions options) async {
final result = await fetchQuery('0', options);
maybeRebroadcastQueries();
return result;
}


Future<QueryResult> 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(
Expand All @@ -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;
Expand Down

0 comments on commit 0c6b0e7

Please sign in to comment.