apollo-angular: Apollo has a constructor which is not compatible with Dependency Injection. It should probably not be @Injectable().
I was following documentation from the https://www.apollographql.com/docs/angular/basics/setup/ trying to install Apollo Angular.
After running ng add apollo-angular and updating API endpoint in the graphql.module.ts, I’m getting Apollo has a constructor which is not compatible with Dependency Injection. It should probably not be @Injectable(). when trying to inject Apollo from apollo-angular in any component or service.
Angular version: 8.2.11
Angular Apollo version: 1.8.0
How this could be resolved?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 11
- Comments: 19 (2 by maintainers)
There’s no stable Angular 9 yet so you guys please give me time to solve it. I started creating
apollo-angularwhen Angular was in alpha, then in beta and then they changed bunch of stuff in one of RCs.As @Vilsol pointed out. It’s no longer an issue in
9.0.0-rc.2.It’s an open-source project and I’m the only one developing it (Apollo Team haven’t pushed a single line of code). If you want to help, please provide reproductions or even pull requests, this speeds up things a lot.
@kamilkisiela I want to personally thank you for all your work. This project is awesome. I really do appreciate you taking the time to look into this. Thank you.
I am only having this issue when running unit tests. is there any solution for this already?
It’s taking time. We need to fix that
Anyone working on this? Update: Going to post my findings as tracking down bug: File in question: src/Apollo.ts
Looking to see what changed with constructor to make it so that it thinks this shouldn’t be an injectable
@angular/core/core.d.tsfile to see if anything recently changed in declaration file. Will tell if has to do with recent change here, or in @angular/coreAt this point stuck: Trying to figure out why
__ivy_ngcc__is automatically being added to package, and new builds that I am making aren’t being picked up? At this time rolling back packages, so can continue working on app. I do not know core contributors personally, but would love if can reach out to charlie@razroo.com, so that we can talk. Thank you.This issue only shows up for me when
"angularCompilerOptions": { "enableIvy": true },Hope it can be resolved soon!@Maximaximum Good to know. I can confirm that I have the DI Problems when using jest and the generated queries from graphql code generator.
Yes. I was using jest with Angular
Op do 9 sep. 2021 12:50 schreef Maksym Kobieliev @.***>:
@kamilkisiela could you please reopen this one?
Same issue for me…
This error look like something that could be related to (https://next.angular.io/guide/ivy-compatibility)
May this library could help to validate apollo ?!: https://github.com/angular/ngcc-validation