zino-hofmann / graphql-flutter

A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.
https://zino-hofmann.github.io/graphql-flutter
MIT License
3.23k stars 608 forks source link

Failed to lookup host on all versions error #1417

Open mariugo opened 3 months ago

mariugo commented 3 months ago

I’m getting a host lookup error, which I can bypass by running the project without Uncaught Exceptions. I also use this endpoint/graph on the web, via React: apollo/client 3.8.1 and get no erros.

What I would like to know is if there is any configuration on the server side in Apollo("@apollo/server": "4.0.4") in order to avoid this issue. As I said before, the app runs, but not with errors.

I’m currently using: graphql: ^5.1.3 graphql_flutter: ^5.1.2 http: ˆ1.2.0 Flutter 3.19.3, testing it from macOS M1:

My connection goes through http, but there’s also dio on the project for its own reasons, not sure if it would make any difference changing to it. Code implementation below:

@override
  Future<http.StreamedResponse> send(http.BaseRequest request) {
    return _client
        .send(request)
        .timeout(const Duration(seconds: 30))
        .then((response) async {
      if (response.headers.containsKey('api-update-warning')) {
        GetIt.I.get<OttoNotificationCenter>().notifyNewVersionAvailable();
      }
      if (response.statusCode == 400) {
        final responseString = await response.stream.bytesToString();
        if (responseString.contains('FORBIDDEN_API_VERSION')) {
          GetIt.I.get<OttoNotificationCenter>().notifyForbiddenApiVersion();
          throw NotAllowedAPIVersionException();
        } else if (responseString.contains('UNAUTHENTICATED')) {
          GetIt.I.get<OttoNotificationCenter>().notifyUserUnauthenticated();
          throw UnauthenticatedException();
        }
      }
      return response;
    });
  }
}

To Reproduce (MUST BE PROVIDED)

My connection goes through http, but there’s also dio on the project for its own reasons, not sure if it would make any difference changing to it.

This is the error I get through any query, mutation and so on:

  1. When I use 'graphql' '5.1.3' and 'http' '1.2.0' only with Uncaught Exceptions on VS Code checked
  2. I receive the following error from socket_patch.dart:
    
    Line: 520
    if (isErrorResponse(response)) {
        throw createError(response, "Failed host lookup: '$host'");
      }
    Response [ 
    No address associated with hostname
    ]

Line: 633 final addresses = await lookup(host, type: type); Host: [dev.otto.com.vc]. // which goes to: (dev.otto.com.vc/graphql) Type: InternetAdressType: IPv6



3. But I would like to receive 'No host lookup erros since it does not normally appear. '

**Expected behavior**
Because it does run if Uncaught Exceptions is not checked, I would like either to solve on the client/flutter side or even if there's a chance or any docs to resolve it under the server side.

**device / execution context**
Simulator, Android emulator and physical devices all throught requests on API published on AWS

### Other useful/optional fields

**additional context**
* What backend are you trying to use? Apollo 4 in AWS.
* If you have a network issue, does your operation work with [GraphiQL](https://www.electronjs.org/apps/graphiql)? It does work.

**additional notes**
I am new to GraphQL