Closed darkbasic closed 6 years ago
Did you try to use ApolloQueryObservable<..>
instead of Observable<ApolloQueryResult<...>>
?
Also, if it does not work, I would expect the result.data.allMembers
to be marked as syntax error...
@darkbasic
Did you try to use ApolloQueryObservable<..> instead of Observable<ApolloQueryResult<...>>?
No, because I'm using apollo-client 2.0 and AFAIK I am supposed to use Observable<ApolloQueryResult<...>> with latest version:
export class QueryRef<T> {
public valueChanges: Observable<ApolloQueryResult<T>>;
Also, if it does not work, I would expect the result.data.allMembers to be marked as syntax error...
Webstorm has several ways to infer types (it also looks for the text string to see if it has been used elsewhere, etc..), but if you CTRL + mouse hover on result
it clearly shows that it's of type any
:
@darkbasic maybe it's because of the map
usage?
The signature of map
in rxjs
is:
export function map<T, R>(this: Observable<T>, project: (value: T, index: number) => R, thisArg?: any): Observable<R> {
return higherOrderMap(project, thisArg)(this);
}
Did you try to add the output type as generic for map
?
Did you try to add the output type as generic for map?
If you mean something like
const a = query.valueChanges.map<ApolloQueryResult<AllMembers.Query>, AllMembers.AllMembers[]>(result => result.data.allMembers);
it indeed works, but why should I need to specify something like that? It should be able to automatically infer it, in fact it already knows that query.valueChanges
returns Observable<ApolloQueryResult<AllMembers.Query>>
:
With apollo-client 1.x it already worked that way.
Uhm... that's strange, maybe it's a bug in Webstorm?
https://youtrack.jetbrains.com/issue/WEB-29502
If you use Webstorm please vote for this issue.
@darkbasic , it makes sense. Also, which version of typescript
do you use? And which version is in use in WebStorm settings?
2.4.2
@darkbasic same for me, with 2.5/2.6. I guess that it's a WebStorm issue. Do you think we can close the issue?
Yes I think so. Thanks.
Test code: https://github.com/darkbasic/angularcli-graphql
/src/app/apollo/apollo.component.ts