Closed pfrendo closed 7 years ago
Removing a logic from lift
method means that now it's not possible to use apollo specific methods after using an operator.
An example:
const obs = new RxObservableQuery(apolloObs)
.map(({data}) => data.products);
// and later use
obs.refetch();
@kamilkisiela, it seems impossible to extend it at it currently stands for some weird reason.
You can still use specific methods but you have to include the type for RxObservableQuery..
As seen in the tests from :
RxObservableQuery<heroes.AllHeroesQueryResult>
you will need to specify the whole type..
RxObservableQuery<ApolloQueryResult<heroes.AllHeroesQueryResult>>
@kamilkisiela , can we discuss this please.. As I personally need this :)
Hello, any updates on this? Thanks!
@kamilkisiela ... Any update?
@pfrendo I'll take a look on it tomorrow
@kamilkisiela This should solve #36 as well, right?
@kamilkisiela ... any update please????
Is it nearly fixed? :)
Any update here? Would love to get this in so can use the latest versions again! @kamilkisiela
@lukemadera in the meantime do you have a version number I can use that works? This is my first adventure in the Apollo world and I can't seem to get it working 😞
@jjenzz With typescript@2.3.4 it's working fine.
@mwld Thank you. I switched version and my app compiled if I set the property type to Observable<any>
. However, my editor (vscode) was still complaining:
[ts]
The 'this' context of type 'ApolloQueryObservable<{}>' is not assignable to method's 'this' of type 'Observable<ApolloQueryResult<any>>'.
Types of property 'lift' are incompatible.
Type '<R>(operator: Operator<ApolloQueryResult<{}>, ApolloQueryResult<R>>) => Observable<ApolloQueryRes...' is not assignable to type '<R>(operator: Operator<ApolloQueryResult<any>, R>) => Observable<R>'.
Types of parameters 'operator' and 'operator' are incompatible.
Type 'Operator<ApolloQueryResult<any>, R>' is not assignable to type 'Operator<ApolloQueryResult<{}>, ApolloQueryResult<{}>>'.
Type 'R' is not assignable to type 'ApolloQueryResult<{}>'.
For anyone else that may have a similar issue, this fixed it for me: https://github.com/angular/angular/issues/17800#issuecomment-315446200
@jjenzz what fixed it for you? Reverting typescript to 2.3.4? Or were you able to get it to work with an up to date typescript?
Can we at least have an approx. date when the fix is going to be released? I'm stuck. apollo-client-rxjs can't use 4.1.0 and another library depends on ^4.1.0
quick walk around
(this.apollo.watchQuery({query, variables, fetchPolicy}) as any).map(({data}) => this.handleResponseData(data)
I've added "skipLibCheck": true
, to my tsconfig.app.json
as a workaround
Workaround suggested by @b091 actually works.
Updating to typescript@2.5.2
(and apollo-client@1.9.2
) did not produce these errors that I experienced with typescript@2.4.x
.
I can confirm this. typescript@2.4.x + apollo-client@1.9.2 do work now.
What was missing in my code was the generic type for the return value - you might want to check this.
// Pseudo code
myQuery(): ApolloQueryResult<myResultType> {
// ...
return this.apollo.query<myResultType>(...)
}
myWatchQuery(): ApolloQueryObservable<myResultType> {
// ...
return this.apollo.watchQuery<myResultType>(...)
}
myMutation(): ApolloExecutionResult<myResultType> {
// ...
return this.apollo.mutate<myResultType>(...)
}
This issue still occurs:
"typescript": "~2.5.3" // also failed with 2.4.x and 2.3x "apollo-angular": "^0.13.2", "apollo-client": "^1.9.3",
Try this one
private getCampaigns(): ApolloQueryObservable<QueryResponse> {
return this.apollo.watchQuery<QueryResponse>({
query: query
});
}
as described in my examples above Does this work?
If you use apollo-angular then we changed the way ApolloClient works with RxJS. You can check it here: apollographql/apollo-angular#377
No more this kind of issues.
This has also been testing with an application running typescript 2.4.1 & rxjs 5.4.2