Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update graphql dependency and use features #144

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/nhost_dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies:
nhost_graphql_adapter: ^4.0.7
dev_dependencies:
fake_async: ^1.3.1
graphql: ^5.1.3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, let's not upgrade to beta versions unless there is a very good reason for it

graphql: ^5.2.0-beta.9
lints: any
mockito: ^5.3.2
nock: ^1.2.1
Expand Down
2 changes: 1 addition & 1 deletion packages/nhost_graphql_adapter/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ environment:
sdk: ">=2.18.0 <4.0.0"

dependencies:
graphql: ^5.1.3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, let's not upgrade to beta versions unless there is a very good reason for it

graphql: ^5.2.0-beta.9

# Nhost packages
nhost_dart: ^2.0.7
Expand Down
57 changes: 57 additions & 0 deletions packages/nhost_graphql_adapter/lib/src/create_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,54 @@ import '../nhost_graphql_adapter.dart';
/// requests made by the Nhost APIs, which can be useful for proxy configuration
/// and debugging.
/// {@endtemplate}
///
/// {@template nhost.graphqlClient.defaultPolicies}
/// [defaultPolicies] (optional) customizes the default policies used by the
/// client. This can be used to change the cache-and-network or network-only
/// behavior of the client.
/// {@endtemplate}
///
/// {@template nhost.graphqlClient.alwaysRebroadcast}
/// [alwaysRebroadcast] (optional) if true, the client will rebroadcast watch
/// queries when the underlying cache changes. This is false by default.
/// {@endtemplate}
///
/// {@template nhost.graphqlClient.deepEquals}
/// [deepEquals] (optional) overrides the default deep equals comparison for
/// caching.
/// {@endtemplate}
///
/// {@template nhost.graphqlClient.deduplicatePollers}
/// [deduplicatePollers] (optional) if true, the client will deduplicate
/// duplicate pollers. This is true by default.
/// {@endtemplate}
///
/// {@template nhost.graphqlClient.queryRequestTimeout}
/// [queryRequestTimeout] (optional) overrides the default request timeout for
/// queries. This is 10 seconds by default.
/// {@endtemplate}
GraphQLClient createNhostGraphQLClient(
NhostClientBase nhostClient, {
GraphQLCache? gqlCache,
Map<String, String>? defaultHeaders,
http.Client? httpClientOverride,
DefaultPolicies? defaultPolicies,
bool? alwaysRebroadcast,
DeepEqualsFn? deepEquals,
bool? deduplicatePollers,
Duration? queryRequestTimeout,
}) {
return createNhostGraphQLClientForAuth(
nhostClient.gqlEndpointUrl,
nhostClient.auth,
gqlCache: gqlCache,
defaultHeaders: defaultHeaders,
httpClientOverride: httpClientOverride,
defaultPolicies: defaultPolicies,
alwaysRebroadcast: alwaysRebroadcast,
deepEquals: deepEquals,
deduplicatePollers: deduplicatePollers,
queryRequestTimeout: queryRequestTimeout,
);
}

Expand All @@ -52,12 +88,28 @@ GraphQLClient createNhostGraphQLClient(
/// {@macro nhost.graphqlClient.defaultHeaders}
///
/// {@macro nhost.graphqlClient.httpClientOverride}
///
/// {@macro nhost.graphqlClient.defaultPolicies}
///
/// {@macro nhost.graphqlClient.alwaysRebroadcast}
///
/// {@macro nhost.graphqlClient.deepEquals}
///
/// {@macro nhost.graphqlClient.deduplicatePollers}
///
/// {@macro nhost.graphqlClient.queryRequestTimeout}
///
GraphQLClient createNhostGraphQLClientForAuth(
String nhostGqlEndpointUrl,
HasuraAuthClient nhostAuth, {
GraphQLCache? gqlCache,
Map<String, String>? defaultHeaders,
http.Client? httpClientOverride,
DefaultPolicies? defaultPolicies,
bool? alwaysRebroadcast,
DeepEqualsFn? deepEquals,
bool? deduplicatePollers,
Duration? queryRequestTimeout,
}) {
return GraphQLClient(
link: combinedLinkForNhostAuth(
Expand All @@ -67,5 +119,10 @@ GraphQLClient createNhostGraphQLClientForAuth(
httpClientOverride: httpClientOverride,
),
cache: gqlCache ?? GraphQLCache(),
defaultPolicies: defaultPolicies,
alwaysRebroadcast: alwaysRebroadcast ?? false,
deepEquals: deepEquals,
deduplicatePollers: deduplicatePollers ?? false,
queryRequestTimeout: queryRequestTimeout ?? const Duration(seconds: 5),
Copy link
Contributor Author

@totzk9 totzk9 Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbarrosop would it be much better to increase the request timeout for it let's say 1 or 3 mins to avoid unexpected timeouts when devs updates to the new version?
They might have sudden timeouts when they haven't read the new changes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: the 5 seconds was taken from the default value of the dep itself

Copy link
Contributor Author

@totzk9 totzk9 Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another side note: we should probably wait for this PR to be merged then update the gql_websocket_link dep before we update to v5.2.0-beta.10

);
}
2 changes: 1 addition & 1 deletion packages/nhost_graphql_adapter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ environment:
sdk: ">=2.14.0 <4.0.0"

dependencies:
graphql: ^5.1.3
graphql: ^5.2.0-beta.9
http: ^1.1.0
meta: ^1.7.0

Expand Down
2 changes: 1 addition & 1 deletion packages/nhost_sdk/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies:

dev_dependencies:
fake_async: ^1.3.1
graphql: ^5.1.3
graphql: ^5.2.0-beta.9
lints: any
mockito: ^5.3.2
nock: ^1.2.1
Expand Down