Unable to retrieve errors occured in Graphql mutation in flutter project


I am using the package graphql_flutter for GraphQL operations in my flutter app. The queries and mutations are going well but I cannot retrieve the errors by following the ways mentioned in their doc. Every time I receive a generic error message which is,

ClientException: Failed to connect to 

That I get by doing,


My mutation looks like,

final MutationOptions mutationOptions = MutationOptions(
  documentNode: gql(mutationString),
  variables: vars

final QueryResult result = await _instance._client.mutate(mutationOptions);

if (result.hasException) {
  // none of the following prints the expected error.


return result.data;

Whereas in the apollo client, My error is :

  "errors": [
      "message": "Invalid Phone number provided",
      "locations": [
          "line": 2,
          "column": 3
      "path": [
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",

But I get none of that.

Note: The success response is coming as expected. I would like to know how can I get the graphql errors.


I found the problem. It is because android cannot connect to or localhost from the emulator. I replaced the host with my local IP address and it is working fine now.

Answered By – Anik

Answer Checked By – Pedro (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *