nhost / nhost-dart

Nhost Dart & Flutter packages
https://nhost.io
MIT License
90 stars 33 forks source link

Unable to change 5 seconds Timeout in the SDK #143

Open totzk9 opened 3 weeks ago

totzk9 commented 3 weeks ago

The graphql-v5.2.0-beta.9 dependency package being used in nhost-dart SDK added a 5 second timeout which causes Nhost apps to fail abrupty.

graphql-v5.2.0-beta.9 related commit: https://github.com/zino-hofmann/graphql-flutter/commit/6180841e9b703d9c312ea29e575dece973c691bc

We should add an optional parameter to be able to increase the Timeout in createNhostGraphQLClientForAuth.

Screenshot 2024-10-30 at 4 17 59 PM

totzk9 commented 3 weeks ago

Currently working on a PR for this.

dbarrosop commented 3 weeks ago

Awesome, thanks for the report and for the PR :)

totzk9 commented 3 weeks ago

For anyone who uses the latest and wants to override the timeout when doing: dependencies or dependency_overrides in their project

dependency:
  graphql: ^5.2.0-beta.9

You can just create your own createNhostGraphQLClientForAuth function:

import 'package:graphql/client.dart';
import 'package:http/http.dart' as http;
import 'package:nhost_gql_links/nhost_gql_links.dart';
import 'package:nhost_sdk/nhost_sdk.dart';

GraphQLClient createNhostGraphQLClient(
  NhostClientBase nhostClient, {
  Map<String, String>? defaultHeaders,
  http.Client? httpClientOverride,
  GraphQLCache? gqlCache,
  DefaultPolicies? defaultPolicies,
  bool? alwaysRebroadcast,
  DeepEqualsFn? deepEquals,
  bool? deduplicatePollers,
  Duration? queryRequestTimeout,
}) {
  return GraphQLClient(
    link: combinedLinkForNhostAuth(
      nhostClient.gqlEndpointUrl,
      nhostClient.auth,
      defaultHeaders: defaultHeaders,
      httpClientOverride: httpClientOverride,
    ),
    cache: gqlCache ?? GraphQLCache(),
    defaultPolicies: defaultPolicies,
    alwaysRebroadcast: alwaysRebroadcast ?? false,
    deepEquals: deepEquals,
    deduplicatePollers: deduplicatePollers ?? false,
    queryRequestTimeout: queryRequestTimeout ?? const Duration(seconds: 60),
  );
}