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
Browse files Browse the repository at this point in the history
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 committed Sep 28, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent c96e9c2 commit 320edd2
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
@@ -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 320edd2

Please sign in to comment.