If I disconnect the internet during a graphql query, the code never throws an exception and never continues to the next line.
Steps to reproduce
Expected behavior
I believe an exception should be thrown.
Sample code:
try {
GraphQLClient client = GraphQLClient(
cache: InMemoryCache(),
link: link,
);
print('start query');
final result = await client.query( // disconnect the internet during this function
QueryOptions(
documentNode: gql(myQuery),
variables: myVariables,
),
);
print('end query'); // this is never printed
} catch (e) {
print('error'); // this is never printed
}
I thought on using CancelableOperation to make some kind of timeout, but the actual function would still be running on the background.
Am I doing something wrong?
Any help would be appreciated.
Smartphone:
Package:
Additional Info:
位 flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[鈭歖 Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows [Version 10.0.17134.1246], locale ja-JP)
[鈭歖 Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[鈭歖 Android Studio (version 3.5)
[!] IntelliJ IDEA Ultimate Edition (version 2018.3)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[鈭歖 VS Code (version 1.41.1)
[鈭歖 Connected device (1 available)
! Doctor found issues in 1 category.
I got the same error
I think you can use an ErrorLink where your Link is.
Confirming the issue.
I think you can use an
ErrorLinkwhere yourLinkis.
Could you elaborate? I got the exact same code, my link is an HttpLink (with uri=serveradress). What would I need to change to e.g: the following code:
class GraphQLConfiguration {
static HttpLink httpLink = HttpLink(
uri: "https://link.to.server.com",
);
ValueNotifier<GraphQLClient> client = ValueNotifier(
GraphQLClient(
link: httpLink,
cache: OptimisticCache(dataIdFromObject: typenameDataIdFromObject),
),
);
GraphQLClient clientToQuery() {
return GraphQLClient(
cache: OptimisticCache(dataIdFromObject: typenameDataIdFromObject),
link: httpLink,
);
}
}
+1
Same problem
Any progress here? This is very annoying issue.
It would very nasty to go to each query and set timeouts....
any progress?
any progress?
Most helpful comment
Any progress here? This is very annoying issue.
It would very nasty to go to each query and set timeouts....