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

Update onComplete handler typings #3648

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Update onComplete handler typings #3648

wants to merge 6 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Oct 30, 2019

Fixes #3546

Checklist:

  • N/A – If this PR is a new feature, please reference an issue where a consensus about the design was reached (not necessary for small changes)
  • N/A – Make sure all of the significant new logic is covered by tests
  • N/A – If this was a change that affects the external API used in GitHunt-React, update GitHunt-React and post a link to the PR in the discussion.

@apollo-cla
Copy link

@SophieDonut: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

@vieiralucas
Copy link

I have been bitten by TypeError: undefined is not an object too many times because Typescript can't help me remember to check if this is undefined

Please someone merge this

@richeterre
Copy link

@hwillson Would it be possible to get this merged?

We're getting frequent crashes due to onCompleted getting called with data being undefined when the type system says it shouldn't 😬

@ghost ghost requested a review from hwillson January 15, 2020 10:05
@victorlevasseur
Copy link

@SophieDonut Now that the dev of the client is happening on the apollo-client repository, I think you have little chance of you're PR getting reviewed.

In the v3.0 beta doc, I see this about the onCompleted handler (on the useQuery/useMutation hooks) :

onCompleted | (data: TData | {}) => void | A callback executed once your query successfully completes.

So it seems that data can't be really undefined but just an empty object. So you'll need to test your root attributs for being defined before doing anything with them. It makes sense with what we observed on our apps (but we have big issues trying to repro it)

@hwillson hwillson removed their request for review April 8, 2020 11:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Types on onCompleted incomplete, should include undefined
4 participants