apollographql/apollo-client

`MockLink` doesn't work with `@nonreactive` directive.

broyde opened this issue · 2 comments

Issue Description

The same query is used for main code and mocked response in test.
This works fine until we add @nonreactive directive to this query.
Query example:

const query = gql`
query TestQuery {
  photos {
    id
    url @nonreactive
  }
}
`;

Warning example:

     No more mocked responses for the query: query TestQuery {
        photos {
          id
          url
          __typename
        }
      }
      Expected variables: {}

Whole test: https://github.com/broyde/apollo-mock-nonreactive/blob/main/nonreactive.test.js

It would be great to automatically remove @nonreactive from mocks passed to MockLink/MockedProvider.
It should help to match actually performed query with the mocked one.

Link to Reproduction

https://github.com/broyde/apollo-mock-nonreactive

Reproduction Steps

No response

@apollo/client version

3.9.11

Hey @broyde!

Thanks for bringing this to our attention! It looks like we might need to run internal document transforms on the queries passed to MockLink to ensure they match. I don't have a timeline on a fix for this, but we'll take a look when we get to it. Again, thanks for reporting it!