diff --git a/packages/graphql/lib/src/core/query_manager.dart b/packages/graphql/lib/src/core/query_manager.dart index 1a7351fb..375707f0 100644 --- a/packages/graphql/lib/src/core/query_manager.dart +++ b/packages/graphql/lib/src/core/query_manager.dart @@ -35,6 +35,7 @@ class QueryManager { this.alwaysRebroadcast = false, DeepEqualsFn? deepEquals, bool deduplicatePollers = false, + this.requestTimeout = const Duration(seconds: 5), }) { scheduler = QueryScheduler( queryManager: this, @@ -51,6 +52,9 @@ class QueryManager { /// Whether to skip deep equality checks in [maybeRebroadcastQueries] final bool alwaysRebroadcast; + /// The timeout for resolving a query + final Duration requestTimeout; + QueryScheduler? scheduler; static final _oneOffOpId = '0'; int idCounter = 1; @@ -256,8 +260,7 @@ class QueryManager { try { // execute the request through the provided link(s) - response = - await link.request(request).timeout(Duration(seconds: 5)).first; + response = await link.request(request).timeout(this.requestTimeout).first; queryResult = mapFetchResultToQueryResult( response, diff --git a/packages/graphql/lib/src/graphql_client.dart b/packages/graphql/lib/src/graphql_client.dart index 357419b8..6d7a1edf 100644 --- a/packages/graphql/lib/src/graphql_client.dart +++ b/packages/graphql/lib/src/graphql_client.dart @@ -28,6 +28,7 @@ class GraphQLClient implements GraphQLDataProxy { bool alwaysRebroadcast = false, DeepEqualsFn? deepEquals, bool deduplicatePollers = false, + Duration queryRequestTimeout = const Duration(seconds: 5), }) : defaultPolicies = defaultPolicies ?? DefaultPolicies(), queryManager = QueryManager( link: link, @@ -35,6 +36,7 @@ class GraphQLClient implements GraphQLDataProxy { alwaysRebroadcast: alwaysRebroadcast, deepEquals: deepEquals, deduplicatePollers: deduplicatePollers, + requestTimeout: queryRequestTimeout, ); /// The default [Policies] to set for each client action