Intended outcome:
Apollo 3 seems to have introduced the undocumented breaking change.
Previously the data field of ApolloQueryResult was not optional, now it is. In the TypeScript environment that forces us to always guard the data to assure it is there. To wrap my mind around it I tried to get undefined from the query but was never successful.
There is no explanation of why it is optional now in neither migration neither in queries document.
My guesses:
Actual outcome:
Data is always optional, forcing a lot of if statements or filter operators with rxjs.
Versions
System:
OS: macOS 10.15.5
Binaries:
Node: 12.18.2 - ~/.nvm/versions/node/v12.18.2/bin/node
Yarn: 1.22.4 - ~/Projects/censhare-hub/node_modules/.bin/yarn
npm: 6.14.6 - ~/.nvm/versions/node/v12.18.2/bin/npm
Browsers:
Chrome: 85.0.4183.83
Edge: 85.0.564.44
Firefox: 79.0
Safari: 13.1.1
npmPackages:
@apollo/client: ^3.0.0 => 3.1.4
@apollo/link-persisted-queries: ^1.0.0-beta.0 => 1.0.0-beta.0
apollo: ^2.30.3 => 2.30.3
apollo-angular: ^2.0.4 => 2.0.4
This seems to be an (unintended and unnecessary) consequence of 144155c5b16dd36f052d8f7f9401bde51162b8b4, which was part of #6080. Fortunately, removing the ? should not be a breaking change, since it strengthens the type of the data field, strictly reducing the number of possibilities that need to be considered.
Most helpful comment
This seems to be an (unintended and unnecessary) consequence of 144155c5b16dd36f052d8f7f9401bde51162b8b4, which was part of #6080. Fortunately, removing the
?should not be a breaking change, since it strengthens the type of thedatafield, strictly reducing the number of possibilities that need to be considered.