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

Commit

Permalink
fix issue with variable merging (#139)
Browse files Browse the repository at this point in the history
* fix issue with variable merging

* update changelog and version

* fix version numbers
  • Loading branch information
James Baxley authored Aug 14, 2016
1 parent 58eb6d1 commit 7c5980a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
11 changes: 8 additions & 3 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@

Expect active development and potentially significant breaking changes in the `0.x` track. We'll try to be diligent about releasing a `1.0` version in a timely fashion (ideally within 1 or 2 months), so that we can take advantage of SemVer to signify breaking changes from that point on.

### v4.0.3

### v0.4.4

- Bug: Fixed issue with variable merging [#139](https://github.com/apollostack/react-apollo/pull/139)

### v0.4.3

- Feature: Support a different store in the tree that is immutable (support immutable redux) [#137](https://github.com/apollostack/react-apollo/pull/137)

### v4.0.2
### v0.4.2

- Bug: Fixed refetch methods when no result is returned

### v4.0.1
### v0.4.1

- BREAKING Feature: [Brand new API! See the docs for more information](http://docs.apollostack.com/apollo-client/react.html);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-apollo",
"version": "0.4.3",
"version": "0.4.4",
"description": "React data container for Apollo Client",
"main": "index.js",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions src/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ export default function graphql(

// XXX use passed loading after https://github.com/apollostack/apollo-client/pull/467
const { queryId } = observableQuery;
const currentVariables = this.store.getState()[reduxRootKey].queries[queryId].variables;
let currentVariables = this.store.getState()[reduxRootKey].queries[queryId].variables;
const resultKeyConflict: boolean = (
'errors' in data ||
'loading' in data ||
Expand Down Expand Up @@ -448,10 +448,10 @@ export default function graphql(
let newVariables = vars;
const newData = { loading: true } as any;
if (vars && (vars.variables || vars.query || vars.updateQuery)) {
newVariables = vars.variables;
newVariables = assign({}, this.data.variables, vars.variables);
newData.variables = newVariables;
}

if (newVariables) newData.variables = newVariables;
this.data = assign(this.data, newData);

this.hasOperationDataChanged = true;
Expand Down
9 changes: 5 additions & 4 deletions test/react-web/client/graphql/queries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -515,12 +515,12 @@ describe('queries', () => {

it('exposes fetchMore as part of the props api', (done) => {
const query = gql`
query people($skip: Int) { allPeople(first: 1, skip: $skip) { people { name } } }
query people($skip: Int, $first: Int) { allPeople(first: 1, skip: $skip) { people { name } } }
`;
const data = { allPeople: { people: [ { name: 'Luke Skywalker' } ] } };
const data1 = { allPeople: { people: [ { name: 'Leia Skywalker' } ] } };
const variables = { skip: 1 };
const variables2 = { skip: 2 };
const variables = { skip: 1, first: 1 };
const variables2 = { skip: 2, first: 1 };

const networkInterface = mockNetworkInterface(
{ request: { query, variables }, result: { data } },
Expand All @@ -536,7 +536,7 @@ describe('queries', () => {
expect(props.data.fetchMore).to.be.exist;
expect(props.data.fetchMore).to.be.instanceof(Function);
props.data.fetchMore({
variables: variables2,
variables: { skip: 2 },
updateQuery: (prev, { fetchMoreResult }) => ({
allPeople: {
people: prev.allPeople.people.concat(fetchMoreResult.data.allPeople.people),
Expand All @@ -545,6 +545,7 @@ describe('queries', () => {
});
// XXX add a test for the result here when #508 is merged and released
} else if (count === 1) {
expect(props.data.variables).to.deep.equal(variables2);
expect(props.data.loading).to.be.true;
expect(props.data.allPeople).to.deep.equal(data.allPeople);
} else if (count === 2) {
Expand Down

0 comments on commit 7c5980a

Please sign in to comment.