...
- Fix memory leak issue (thanks @msimulcik!).
- Add
graphqlErrors
prop to query mock config, to support returning actual GraphQL errors, and not just server errors.
- Fixes bug with operation names not properly picked up when fragments appear before the operation in the query, courtesy of @msimulcik.
- Drop support for Node < 8.
- Improved error messages for missing mocks.
- Variables now match regardless of property order in variable objects.
- Adds a method to clean up
nock
.
- Updating TypeScript definitions.
customHandler
can now be async and return a promise. This should simplify experimenting with automocking and other things needing async.
- Bug fix from accidental mutation. Mutability is fun, but hard!
- Added
ignoreThesePropertiesInVariables: Array<string>
to the mock config, which basically is a more convenient way of filtering out unstable variables you may use in your queries (like dates). - Support mocking the same query multiple times with different variables without needing to resort to re-mocking after a query mock has been used. This should be quite a bit more convenient, allowing you to do something like this:
queryMock.mockQuery({
name: 'SomeQuery',
variables: {
first: true
},
data: firstData
});
queryMock.mockQuery({
name: 'SomeQuery',
variables: {
second: true
},
data: secondData
});
...instead of like before:
queryMock.mockQuery({
name: 'SomeQuery',
variables: {
first: true
},
data: firstData
});
/**
* Your operation consuming the mock would have to be run and done before you could re-mock the query
* to return your second response.
*/
someThingThatConsumesTheQueryAbove();
queryMock.mockQuery({
name: 'SomeQuery',
variables: {
second: true
},
data: secondData
});
- Greatly improved error messages.
graphql-query-test-mock
will now print all sorts of (hopefully) helpful information about why your mock failed, like exactly why the variables did not match, what queries are currently mocked and so on. Try it!
- TypeScript bindings (thanks to @chagasaway!).
- Automatically discover the name of the query/mutation, removing the need to provide an explicit id/name for every operation.
- Allow to set a custom error that
nock
throws when the mock tells the server to fail (thanks to @chagasaway!).