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 613 forks source link

Executing the same query in parallel only makes one request #1384

Open anchao-lu opened 10 months ago

anchao-lu commented 10 months ago

Describe the issue Executing the same query in parallel only makes one request

To Reproduce (MUST BE PROVIDED)

like this

int i = 0;
    while (i < 5) {
      GqlQueries.getUploadUrl();
      i++;
    }

  static Future<Map> getUploadUrl({
    String ext = 'mp4',
    String ct = 'video/mp4',
  }) async {
    Log.d('send video msg time: ${DateTime.now()}');
    final query = QueryOptions(
      document: gql(Gqls.getUploadUrl),
      variables: {
        'ext': ext,
        'ct': ct,
      },
      fetchPolicy: FetchPolicy.networkOnly,
    );
    final urlData = await gqlClient.query(query);
    final result = urlData.data?['getUploadUrl'] as Map? ?? {};
    Log.d('send video msg accessUrl: ${result['accessUrl']}');
    Log.d('send video msg thumbUrl: ${result['thumbUrl']}');
    return result;
  }

Expected behavior make five requests

Result behavior only makes one request

device / execution context any

How do I get expected behavior?