You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Intended outcome:
According to apollographql/react-apollo#3388, unavailable data should not be {} but undefined. One reason mentioned in the PR makes a lot of sense (especially using codegen) :
Forcing no data situations to be empty objects can go against application schemas that enforce a value and don't allow empty objects.
Actual outcome:
It's actually still {} between refetches, when nothing's found in the cache, essentially giving two different semantics for "there's no data" : undefined on initial fetch, then {}. This feels inconsistent and generates nasty runtime errors that are not catched by TypeScript when using codegen.
It also makes patterns like these (recommended here : #6603 (comment)) pointless :
constcontinuousData=data??previousData
How to reproduce the issue:
CodeSandbox Link
Let the first page load, then move to another page. Finally, read the data value in the console :
Intended outcome:
According to apollographql/react-apollo#3388, unavailable
data
should not be{}
butundefined
. One reason mentioned in the PR makes a lot of sense (especially using codegen) :Actual outcome:
It's actually still
{}
between refetches, when nothing's found in the cache, essentially giving two different semantics for "there's no data" :undefined
on initial fetch, then{}
. This feels inconsistent and generates nasty runtime errors that are not catched by TypeScript when using codegen.It also makes patterns like these (recommended here : #6603 (comment)) pointless :
How to reproduce the issue:
Let the first page load, then move to another page. Finally, read the
data
value in the console :Versions
@apollo/client: ^3.3.6 => 3.3.6
The text was updated successfully, but these errors were encountered: