This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 786
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the default query
data
state from {}
to undefined
React Apollo returns an empty object for the initial `data` value, that is returned when performing a query. There a long history behind why this is the case, but this single issue has caused a lot of frustration over the past long while due to the following: - `{}` is not the same as having no data; it's an object, not nothing. If there is no data, we shouldn't pretend there is. - Setting `data` to `{}` isn't followed in all cases; e.g. when errors occur, during parts of SSR, when skipping, etc. This leads to developers having to know when to expect `{}` and when to expect `undefined`. - Forcing no data situations to be empty objects can go against application schemas that enforce a value and don't allow empty objects. This commit adjusts React Apollo's default query `data` state to be `undefined`, and will no longer convert `data` to an empty object if the returned data is falsy. Using `undefined` as the initial state has also been aligned across all parts of RA querying, including SSR. Unfortunately, we missed the opportunity to address this as part of the React Apollo 3.0 launch. This change can be considered breaking, and we can't do another major version bump to get this in (3.0 is the last major version of React Apollo, as React Apollo is being merged into the Apollo Client project). We'll have to put some thought into how we can roll this out. Fixes #3323.
- Loading branch information
Showing
6 changed files
with
64 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters