Closed arni1981 closed 2 years ago
Thank you @arni1981 for the report!
Sorry but I'm not adding a lot here but just labeling it according to our new Contribution Guide and issue flow.
A way to move this forward would be to send us a PR for a fix.
Thank you and sorry that this comment is not a complete solution (yet).
Hey, great that this got fixed! This issue is tagged with "alpha-release-testing" - is there an alpha release of the npm package we could test?
Hey @Yogu , you are actually right, there's no automatic alpha releases for this repo (the tags are standard for The Guild repos, most of them do have it). Anyway, we'll manually release an alpha later today, I'll link it here.
3.0.0-alpha.2
I got this error trying to test 3.0.0-alpha.2
My dependencies
"dependencies": { "@angular/animations": "~13.0.0", "@angular/cdk": "13.0.3", "@angular/common": "~13.0.0", "@angular/compiler": "~13.0.0", "@angular/core": "~13.0.0", "@angular/forms": "~13.0.0", "@angular/material": "13.0.3", "@angular/platform-browser": "~13.0.0", "@angular/platform-browser-dynamic": "~13.0.0", "@angular/router": "~13.0.0", "@apollo/client": "^3.5.6", "apollo-angular": "3.0.0-alpha.2", "graphql": "^16.1.0", "rxjs": "~7.4.0", "tslib": "^2.3.0", "zone.js": "~0.11.4" }
I got this error trying to test
3.0.0-alpha.2
My dependencies
"dependencies": { "@angular/animations": "~13.0.0", "@angular/cdk": "13.0.3", "@angular/common": "~13.0.0", "@angular/compiler": "~13.0.0", "@angular/core": "~13.0.0", "@angular/forms": "~13.0.0", "@angular/material": "13.0.3", "@angular/platform-browser": "~13.0.0", "@angular/platform-browser-dynamic": "~13.0.0", "@angular/router": "~13.0.0", "@apollo/client": "^3.5.6", "apollo-angular": "3.0.0-alpha.2", "graphql": "^16.1.0", "rxjs": "~7.4.0", "tslib": "^2.3.0", "zone.js": "~0.11.4" }
@heberlopezz that's caused by an incompatibility with GraphQL 16. There's an open issue for that too: https://github.com/kamilkisiela/apollo-angular/issues/1723
I was able to compile it successfully but I got this DI error:
My dependencies:
"@ag-grid-community/all-modules": "^26.2.0", "@ag-grid-community/angular": "^26.2.0", "@ag-grid-enterprise/all-modules": "^26.2.0", "@angular/animations": "~13.0.3", "@angular/cdk": "^13.0.3", "@angular/common": "~13.0.3", "@angular/compiler": "~13.0.3", "@angular/core": "~13.0.3", "@angular/forms": "~13.0.3", "@angular/platform-browser": "~13.0.3", "@angular/platform-browser-dynamic": "~13.0.3", "@angular/router": "~13.0.3", "@apollo/client": "^3.5.6", "@datorama/akita": "^7.0.1", "@fortawesome/fontawesome-free": "^5.15.4", "@juggle/resize-observer": "^3.3.1", "@nebular/date-fns": "^9.0.0", "@nebular/eva-icons": "^9.0.0", "@nebular/theme": "^9.0.0", "@ngneat/until-destroy": "^9.0.0", "@ngx-translate/core": "^14.0.0", "@ngx-translate/http-loader": "^7.0.0", "@rxweb/reactive-form-validators": "^2.1.6", "angular-oauth2-oidc": "^13.0.1", "apollo-angular": "^3.0.0-alpha.2", "date-fns": "^2.27.0", "echarts": "^5.2.2", "eva-icons": "^1.1.2", "gql-query-builder": "^3.5.5", "graphql": "^15.8.0", "guid-typescript": "^1.0.9", "lodash-es": "^4.17.21", "ngx-echarts": "^8.0.1", "normalize.css": "^8.0.1", "rxjs": "~7.4.0", "tslib": "^2.3.0", "zone.js": "~0.11.4"
I was able to compile it successfully but I got this DI error:
My dependencies:
"@ag-grid-community/all-modules": "^26.2.0", "@ag-grid-community/angular": "^26.2.0", "@ag-grid-enterprise/all-modules": "^26.2.0", "@angular/animations": "~13.0.3", "@angular/cdk": "^13.0.3", "@angular/common": "~13.0.3", "@angular/compiler": "~13.0.3", "@angular/core": "~13.0.3", "@angular/forms": "~13.0.3", "@angular/platform-browser": "~13.0.3", "@angular/platform-browser-dynamic": "~13.0.3", "@angular/router": "~13.0.3", "@apollo/client": "^3.5.6", "@datorama/akita": "^7.0.1", "@fortawesome/fontawesome-free": "^5.15.4", "@juggle/resize-observer": "^3.3.1", "@nebular/date-fns": "^9.0.0", "@nebular/eva-icons": "^9.0.0", "@nebular/theme": "^9.0.0", "@ngneat/until-destroy": "^9.0.0", "@ngx-translate/core": "^14.0.0", "@ngx-translate/http-loader": "^7.0.0", "@rxweb/reactive-form-validators": "^2.1.6", "angular-oauth2-oidc": "^13.0.1", "apollo-angular": "^3.0.0-alpha.2", "date-fns": "^2.27.0", "echarts": "^5.2.2", "eva-icons": "^1.1.2", "gql-query-builder": "^3.5.5", "graphql": "^15.8.0", "guid-typescript": "^1.0.9", "lodash-es": "^4.17.21", "ngx-echarts": "^8.0.1", "normalize.css": "^8.0.1", "rxjs": "~7.4.0", "tslib": "^2.3.0", "zone.js": "~0.11.4"
I was able to make it work after importing the apollo module on my app module:
@kamilkisiela are you planning a release soon?
add 3.0.0-alpha.2 to new project we got this
@NgModule({
exports: [ApolloModule],
providers: [
{
provide: APOLLO_OPTIONS,
useFactory: createApollo,
deps: [HttpLink],
},
],
})
export class GraphQLModule {}
but update 2.6.0 to 3.0.0-alpha.2 missing exports
@NgModule({
providers: [
{
provide: APOLLO_OPTIONS,
useFactory: createApollo,
deps: [HttpLink],
},
],
})
export class GraphQLModule {}
Guys we are still waiting for this. Any update on your plans please??
3.0.0-alpha.2
is working fine for me except for one typing mismatch with a newer graphql version (16.x):
Error: node_modules/apollo-angular/types.d.ts:41:18 - error TS2430: Interface 'SubscriptionResult<TData>' incorrectly extends interface 'ExecutionResult<ObjMap<unknown>, ObjMap<unknown>>'.
Types of property 'data' are incompatible.
Type 'TData | undefined' is not assignable to type 'ObjMap<unknown> | null | undefined'.
Type 'TData' is not assignable to type 'ObjMap<unknown> | null | undefined'.
Type 'TData' is not assignable to type 'ObjMap<unknown>'.
41 export interface SubscriptionResult<TData> extends ExecutionResult {
- export interface SubscriptionResult<TData> extends ExecutionResult {
+ export interface SubscriptionResult<TData> extends ExecutionResult<TData> {
I also had to add Apollo
itself as a providers
item (in addition to the APOLLO_OPTIONS
) to my module.
Would be great to see the 3.x release going stable as its currently the only version providing real support for Angular 13x and @apollo/client@3.x
Edit: I'm not using ApolloModule (deprecated/removed already in v2.x)
So, I've been trying to make this work but haven't been successful. Is there a sample minimal angular project that someone can post? Trying to decipher bits and pieces together from comments is not working and pretty annoying.
If this project is dormant, we can maybe move on. Right now it's in the main path for our product to get to angular 13 which was released some time ago. So if anyone has an alternative of for this or a more active fork I'd give that a try.
I can't speak for everyone else, but upgrading apollo-angular to "^3.0.0-alpha.2" resolved the issue for me.
I using graphql-codegen for generating all Angular Services from schemas and stop working on runtime, produce "NullInjectorError: No provider for Apollo!" so i add ApolloModule on import and work well again.
This is my module:
import { HttpClientModule } from '@angular/common/http'
import { NgModule } from '@angular/core'
import { ApolloLink, InMemoryCache } from '@apollo/client/core'
import { setContext } from '@apollo/client/link/context'
import { APOLLO_NAMED_OPTIONS, NamedOptions, ApolloModule } from 'apollo-angular'
import { HttpLink } from 'apollo-angular/http'
import { environment } from '../../../environments/environment'
const uri = environment.graphql
@NgModule({
imports: [HttpClientModule, ApolloModule],
providers: [
{
provide: APOLLO_NAMED_OPTIONS,
useFactory: (httpLink: HttpLink): NamedOptions => {
const basic = setContext((operation, context) => ({
headers: {
accept: 'charset=utf-8'
}
}))
const auth = setContext((operation, context) => {
const token = localStorage.getItem('token')
if (token === null) {
return {}
} else {
return {
headers: {
authorization: `JWT ${token}`
}
}
}
})
return {
client: {
// <-- this settings will be saved by name: newClientName
cache: new InMemoryCache(),
link: ApolloLink.from([basic, auth, httpLink.create({ uri })])
}
}
},
deps: [HttpLink]
}
]
})
export class GraphQLModule {}
You have to add Apollo to the providers list:
@NgModule({
imports: [HttpClientModule],
providers: [
Apollo,
{
provide: APOLLO_OPTIONS,
useFactory: createApollo,
deps: [HttpLink], // HttpLink is loaded before the factory is called
},
],
})
This took me about a week to figure out. Super frustrating and disappointing...
I using graphql-codegen for generating all Angular Services from schemas and stop working on runtime, produce "NullInjectorError: No provider for Apollo!" so i add ApolloModule on import and work well again.
This is my module:
import { HttpClientModule } from '@angular/common/http' import { NgModule } from '@angular/core' import { ApolloLink, InMemoryCache } from '@apollo/client/core' import { setContext } from '@apollo/client/link/context' import { APOLLO_NAMED_OPTIONS, NamedOptions, ApolloModule } from 'apollo-angular' import { HttpLink } from 'apollo-angular/http' import { environment } from '../../../environments/environment' const uri = environment.graphql @NgModule({ imports: [HttpClientModule, ApolloModule], providers: [ { provide: APOLLO_NAMED_OPTIONS, useFactory: (httpLink: HttpLink): NamedOptions => { const basic = setContext((operation, context) => ({ headers: { accept: 'charset=utf-8' } })) const auth = setContext((operation, context) => { const token = localStorage.getItem('token') if (token === null) { return {} } else { return { headers: { authorization: `JWT ${token}` } } } }) return { client: { // <-- this settings will be saved by name: newClientName cache: new InMemoryCache(), link: ApolloLink.from([basic, auth, httpLink.create({ uri })]) } } }, deps: [HttpLink] } ] }) export class GraphQLModule {}
@kamilkisiela thanks for you amazing work with this lib. Is there anything we can do to help on releasing apollo-angular v3 as stable version? Is there any stopper we can help with?
@kamilkisiela same question than @ruizmarc ?
On an Angular 13 project running
ng add apollo-angular
results in this...
To Reproduce
Steps to reproduce the behavior:
Run from terminal
ng add apollo-angular
Expected behavior
Well, I was hoping for this to work :)
Environment: