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

Commit

Permalink
Test changes to ensure type guard isn't needed on result data (#2434)
Browse files Browse the repository at this point in the history
#1983 introduced breaking changes that were missed by the current test suite. These changes were rolled back in #2432, but this test change should help prevent this same issue from happening
again.

Reference: #2424
  • Loading branch information
hwillson authored Sep 28, 2018
1 parent c96e9c2 commit 539b9a8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/client/Query.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1476,4 +1476,24 @@ describe('Query component', () => {
},
);
});

// https://github.com/apollographql/react-apollo/issues/2424
it('should be able to access data keys without a type guard', () => {
const Component = () => (
<AllPeopleQuery query={allPeopleQuery}>
{result => {
if (result.data && result.data.allPeople) {
return null;
}

if (result.data && result.data!.allPeople) {
return null;
}

const { allPeople } = result.data!;
return null;
}}
</AllPeopleQuery>
);
});
});

0 comments on commit 539b9a8

Please sign in to comment.