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

Commit

Permalink
Merge b5ae7a5 into 33c5836
Browse files Browse the repository at this point in the history
  • Loading branch information
bostrom committed Dec 29, 2017
2 parents 33c5836 + b5ae7a5 commit 6a699a9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Changelog.md
Expand Up @@ -3,10 +3,10 @@
### next

- **BREAKING CHANGES**
- typescript - `graphql` parameterized types streamlined for
a) full typing; and b) ease of use; and c) consistency. New parameterized is:
- typescript - `graphql` parameterized types streamlined for
a) full typing; and b) ease of use; and c) consistency. New parameterized is:
`graphql<TProps,TData, TGraphQLVariables, TChildProps>` where none are required and full typing only requires the
first three params (`TChildProps` can be derived). [#1402](https://github.com/apollographql/react-apollo/pull/1402)
first three params (`TChildProps` can be derived). [#1402](https://github.com/apollographql/react-apollo/pull/1402)
- Remove deprecated `operationOptions.options.skip`, use `operationOptions.skip` instead
- Rename type `ProviderProps` to `ApolloProviderProps` [#1467](https://github.com/apollographql/react-apollo/pull/1467)
- Rename `getDataFromTree` type `QueryResult` to `QueryTreeResult` [#1467](https://github.com/apollographql/react-apollo/pull/1467)
Expand All @@ -33,6 +33,7 @@ first three params (`TChildProps` can be derived). [#1402](https://github.com/ap
- Mutation test cleanup [#1480](https://github.com/apollographql/react-apollo/pull/1480)
- Removed react-native from the test suite [#1451](https://github.com/apollographql/react-apollo/pull/1451)
- Add `client` to `Query`'s `QueryResult` [#1488](https://github.com/apollographql/react-apollo/pull/1488)
- Disregard falsy elements when walking tree in SSR [#1495](https://github.com/apollographql/react-apollo/pull/1495)

### 2.0.4
- rolled back on the lodash-es changes from
Expand Down
2 changes: 1 addition & 1 deletion src/getDataFromTree.ts
Expand Up @@ -37,7 +37,7 @@ export function walkTree<Cache>(
return;
}

if (element == null) return;
if (!element) return;

const Component = element.type;
// a stateless functional component or a class
Expand Down
27 changes: 27 additions & 0 deletions test/server/getDataFromTree.test.tsx
Expand Up @@ -41,6 +41,24 @@ describe('SSR', () => {
expect(elementCount).toEqual(1);
});

it('basic element trees with false', () => {
let elementCount = 0;
const rootElement = <div>{false}</div>;
walkTree(rootElement, {}, element => {
elementCount += 1;
});
expect(elementCount).toEqual(1);
});

it('basic element trees with empty string', () => {
let elementCount = 0;
const rootElement = <div>{''}</div>;
walkTree(rootElement, {}, element => {
elementCount += 1;
});
expect(elementCount).toEqual(1);
});

it('basic element trees with arrays', () => {
let elementCount = 0;
const rootElement = [1, 2];
Expand All @@ -50,6 +68,15 @@ describe('SSR', () => {
expect(elementCount).toEqual(2);
});

it('basic element trees with false or null', () => {
let elementCount = 0;
const rootElement = [1, false, null, ''];
walkTree(rootElement, {}, element => {
elementCount += 1;
});
expect(elementCount).toEqual(1);
});

it('functional stateless components', () => {
let elementCount = 0;
const MyComponent = ({ n }) => (
Expand Down

0 comments on commit 6a699a9

Please sign in to comment.