Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with typescript 2.4.1 & rxjs 5.4.2 and update #44

Closed
wants to merge 2 commits into from

Conversation

pfrendo
Copy link

@pfrendo pfrendo commented Jul 10, 2017

No description provided.

@pfrendo
Copy link
Author

pfrendo commented Jul 10, 2017

This has also been testing with an application running typescript 2.4.1 & rxjs 5.4.2

@kamilkisiela
Copy link
Owner

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();

@pfrendo
Copy link
Author

pfrendo commented Jul 10, 2017

@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>>

@pfrendo
Copy link
Author

pfrendo commented Jul 12, 2017

@kamilkisiela , can we discuss this please.. As I personally need this :)

@picosam
Copy link

picosam commented Jul 14, 2017

Hello, any updates on this? Thanks!

@pfrendo
Copy link
Author

pfrendo commented Jul 19, 2017

@kamilkisiela ... Any update?

@kamilkisiela
Copy link
Owner

@pfrendo I'll take a look on it tomorrow

@beagleknight
Copy link

@kamilkisiela This should solve #36 as well, right?

@pfrendo
Copy link
Author

pfrendo commented Jul 24, 2017

@kamilkisiela ... any update please????

@ngocdiep
Copy link

Is it nearly fixed? :)

@lukemadera
Copy link

Any update here? Would love to get this in so can use the latest versions again! @kamilkisiela

@jjenzz
Copy link

jjenzz commented Aug 3, 2017

@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 😞

@mwld
Copy link

mwld commented Aug 4, 2017

@jjenzz With typescript@2.3.4 it's working fine.

@jjenzz
Copy link

jjenzz commented Aug 4, 2017

@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<{}>'.

image

For anyone else that may have a similar issue, this fixed it for me: angular/angular#17800 (comment)

@lukemadera
Copy link

@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?

@kroeder
Copy link

kroeder commented Aug 9, 2017

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

@b091
Copy link

b091 commented Aug 10, 2017

quick walk around

(this.apollo.watchQuery({query, variables, fetchPolicy}) as any).map(({data}) => this.handleResponseData(data)

@amitport
Copy link

I've added "skipLibCheck": true, to my tsconfig.app.json as a workaround

@volodymyrlut
Copy link

Workaround suggested by @b091 actually works.

@KeithGillette
Copy link

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.

@kroeder
Copy link

kroeder commented Sep 8, 2017

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>(...)
}

@pfrendo pfrendo closed this Sep 20, 2017
@raysuelzer
Copy link

This issue still occurs:
image

"typescript": "~2.5.3" // also failed with 2.4.x and 2.3x
"apollo-angular": "^0.13.2",
"apollo-client": "^1.9.3",

@kroeder
Copy link

kroeder commented Oct 19, 2017

Try this one

private getCampaigns(): ApolloQueryObservable<QueryResponse> {
    return this.apollo.watchQuery<QueryResponse>({
        query: query
    });
}

as described in my examples above
Does this work?

@kamilkisiela
Copy link
Owner

kamilkisiela commented Oct 19, 2017

If you use apollo-angular then we changed the way ApolloClient works with RxJS. You can check it here: kamilkisiela/apollo-angular#377

No more this kind of issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet