Open
Description
Describe the bug
When enabling initial loading, the type of valueChanges
on QueryRef
is not correct. The type is as follows:
readonly valueChanges: Observable<ApolloQueryResult<TData>>;
but when enabling intial loading, the data field in the result becomes nullable, which is not reflected in the type.
To Reproduce
- Enable initialLoading in the config
- Add a query similar to the following:
private someQueryRef = this.apollo.watchQuery({
query: SomeQueryDocument,
});
protected tests$ = this.testsRef.valueChanges.pipe(
filter((result) => result.data != null),
map((result) => {
return result.data.someQuery;
}),
);
Typescript Eslint will come up with the error @typescript-eslint/no-unnecessary-condition
on filter((result) => result.data != null)
. However, when removing the filter
statement, you will get a TypeError: result.data is undefined
error. Or am I misinterpreting something?
Expected behavior
The type of data is nullable when initial loading is enabled.
Environment:
├── @angular/[email protected] -> ./node_modules/.pnpm/@[email protected][email protected]/node_modules/@angular/cli
├── @angular/[email protected] -> ./node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@angular/core
├── @apollo/[email protected] -> ./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]__graphql@16._e3a29df517fd676fd5c435d43766e066/node_modules/@apollo/client
├── [email protected] -> ./node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]__@apollo+client@3_e1fef8ba11273a8ad1c04e01fcd397a5/node_modules/apollo-angular
├── [email protected] -> ./node_modules/.pnpm/[email protected]/node_modules/graphql
└── [email protected] -> ./node_modules/.pnpm/[email protected]/node_modules/typescript
Metadata
Metadata
Assignees
Labels
No labels