I want to retry a graphql request when the graphql response has some particular errors. My current code:
QueryResult result = await client.query(
QueryOptions(
documentNode: gql(queries.getNextEpisode),
variables: <String, dynamic>{
'id': id,
'keyType': 'POSTER',
},
),
);
if (result.hasException &&
result.exception.graphqlErrors
.any((element) => element.message.contains("401"))) {
// retry the request
}
I tried the retry package but I think it only works if there is an exception thrown, which I don't think is the case here.
I'm using graphql_flutter: ^3.0.0.