25 lines
658 B
TypeScript
25 lines
658 B
TypeScript
import {NgModule} from '@angular/core';
|
|
import {ApolloModule, APOLLO_OPTIONS} from 'apollo-angular';
|
|
import {HttpLinkModule, HttpLink} from 'apollo-angular-link-http';
|
|
import {InMemoryCache} from 'apollo-cache-inmemory';
|
|
|
|
const uri = 'https://localhost:5001/graphql'; // <-- add the URL of the GraphQL server here
|
|
export function createApollo(httpLink: HttpLink) {
|
|
return {
|
|
link: httpLink.create({uri}),
|
|
cache: new InMemoryCache(),
|
|
};
|
|
}
|
|
|
|
@NgModule({
|
|
exports: [ApolloModule, HttpLinkModule],
|
|
providers: [
|
|
{
|
|
provide: APOLLO_OPTIONS,
|
|
useFactory: createApollo,
|
|
deps: [HttpLink],
|
|
},
|
|
],
|
|
})
|
|
export class GraphQLModule {}
|