title: Flutter test GraphQL query
body: <p>I want to test my GraphQL Query. I have my GraphQL client, and I use a remote datasource to do my requests.</p>
  <pre><code>class MockGraphQLClient extends Mock implements GraphQLClient {}
  
  void main() {
    RemoteDataSource RemoteDataSource;
    MockGraphQLClient mockClient;
  
    setUp(() {
      mockClient = MockGraphQLClient();
      RemoteDataSource = RemoteDataSource(client: mockClient);
    });
    group('RemoteDataSource', () {
      group('getDetails', () {
        test(
            'should preform a query with get details with id variable',
            () async {
          final id = &quot;id&quot;;
          when(
            mockClient.query(
              QueryOptions(
                documentNode: gql(Queries.getDetailsQuery),
                variables: {
                  'id': id,
                },
              ),
            ),
          ).thenAnswer((_) async =&gt; QueryResult(
              data: json.decode(fixture('details.json'))['data'])));
  
          await RemoteDataSource.getDetailsQuery(id);
  
          verify(mockClient.query(
            QueryOptions(
              documentNode: gql(Queries.getDetailsQuery),
              variables: {
                'id': id,
              },
            ),
          ));
        });
      });
    });
  }
  </code></pre>
  <p><strong>I would like to know how to mock the response of my query. Currently it does not return a result, it returns null</strong>
  But I don't understand why my query returns null, although I have mocked my client, and in my &quot;when&quot; method I use a &quot;thenAnwser&quot; to return the desired value</p>
  <pre><code>final GraphQLClient client;
  
    ChatroomRemoteDataSource({this.client});
  
    @override
    Future&lt;Model&gt; getDetails(String id) async {
      try {
        final result = await client.query(QueryOptions(
          documentNode: gql(Queries.getDetailsQuery),
          variables: {
            'id': id,
          },
        )); // return =&gt; null ????
  
        if (result.data == null) {
          return [];
        }
        return result.data['details']
      } on Exception catch (exception) {
        throw ServerException();
      }
    }
  </code></pre>