Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

test-link: add stringification to equality check #3078

Merged
merged 3 commits into from
Jun 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
- The result of a mutation is now made available to the wrapped component,
when using the `graphql` HOC. <br/>
[@andycarrell](https://github.com/andycarrell) in [#3008](https://github.com/apollographql/react-apollo/pull/3008)
- Check equality of stringified variables in the `MockLink` to improve
debugging experience used by `MockedProvider`. <br/>
[@evans](https://github.com/evans) in [#3078](https://github.com/apollographql/react-apollo/pull/3078)

### Bug Fixes

Expand Down
53 changes: 20 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
"devDependencies": {
"@types/enzyme": "3.9.3",
"@types/enzyme-adapter-react-16": "1.0.5",
"@types/fast-json-stable-stringify": "^2.0.0",
"@types/graphql": "14.2.0",
"@types/hoist-non-react-statics": "3.3.1",
"@types/invariant": "2.2.29",
Expand Down Expand Up @@ -165,6 +166,7 @@
},
"dependencies": {
"apollo-utilities": "^1.3.0",
"fast-json-stable-stringify": "^2.0.0",
"hoist-non-react-statics": "^3.3.0",
"lodash.isequal": "^4.5.0",
"prop-types": "^15.7.2",
Expand Down
3 changes: 2 additions & 1 deletion src/test-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Observable,
// Observer,
} from 'apollo-link';
import stringify from 'fast-json-stable-stringify';

import { print } from 'graphql/language/printer';
import {
Expand Down Expand Up @@ -67,7 +68,7 @@ export class MockLink extends ApolloLink {
const response = (this.mockedResponsesByKey[key] || []).find((res, index) => {
const requestVariables = operation.variables || {};
const mockedResponseVariables = res.request.variables || {};
if (!isEqual(requestVariables, mockedResponseVariables)) {
if (!isEqual(stringify(requestVariables), stringify(mockedResponseVariables))) {
return false;
}
responseIndex = index;
Expand Down