Intended outcome:
When providing a query to MockedProvider, it works when the exact same query is passed to the Query component.
Actual outcome:
Error: Network error: No more mocked responses for the query.
I have put together a code sandbox that demonstrates the issue pretty clearly: https://codesandbox.io/s/085pqppxn
If you have an @connection directive on the query that is built with gql, when passing it to Query's query prop, it seems that the directive is removed before sending the query over the wire.
However, when passing the same query as a mock to MockedProvider, the directive is left in, resulting in the query never matching and the 'No more mocked responses for the query' happening.
How to reproduce the issue:
See https://codesandbox.io/s/085pqppxn
Version
(both latest at time of submission)
I'm getting the same error in a different situation:
Here is my query
const LOCAL_INVEST_DATA_QUERY = gql`
query {
investAmount @client
investReferenceId @client
userDetails {
email
}
}
`;
Here is my test
const mocks = [
{
request: {
query: LOCAL_INVEST_DATA_QUERY
},
result: {
data: {
investAmount: 10000,
investReferenceId: 'ASD-123-!@#',
userDetails: {
email: '[email protected]'
}
}
}
}
];
describe('Payment form test suite', () => {
test('renders with card option selected', async () => {
const wrapper = mount(
<MockedProvider mocks={mocks} addTypename={false}>
<MyComponent />
</MockedProvider>
);
await wait(2);
wrapper.update();
window.console.log(wrapper.debug());
});
});
Current packages:
"apollo-client": "^2.5.0-beta.0",
"react-apollo": "^2.5.0-beta.1",
The error started happening when i updated from:
"apollo-client": "^2.5.0-alpha.10",
"react-apollo": "^2.4.0-alpha.4",
This was fixed in https://github.com/apollographql/react-apollo/pull/2523. Thanks!
Most helpful comment
I'm getting the same error in a different situation:
Here is my query
Here is my test
Current packages:
The error started happening when i updated from: