Open agborkowski opened 5 years ago
Got the same error in production. Any workaround we can get loona run in angular prod mode?
Found the source of the problem and a solution:
const uri = '/graphql/';
export function apolloFactory(
httpLink: HttpLink,
loonaLink: LoonaLink,
cache: InMemoryCache
): ApolloClientOptions<any> {
const link = loonaLink.concat(
httpLink.create({
uri: uri
})
);
return {
link,
cache
};
}
@NgModule({
imports: [
ApolloModule,
LoonaModule.forRoot([FooState, BarState])
],
exports: [ApolloModule, HttpLinkModule],
providers: [
{
provide: LOONA_CACHE,
useValue: new InMemoryCache() // <-- works in prod mode (with aot)
// useFactory() { <-- does NOT work with aot (in prod mode)
// return new InMemoryCache();
// }
},
{
provide: APOLLO_OPTIONS,
useFactory: apolloFactory,
deps: [HttpLink, LoonaLink, LOONA_CACHE]
}
]
})
export class GraphqlModule {
}
ng build --prod generates