@ovyn/graphql
v2.0.1
Published
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 16.1.0.
Downloads
6
Maintainers
Readme
@Ovyn/Graphql
This library was generated with Angular CLI version 16.1.0.
Usage
Configuration
- Module import
GraphqlModule
- Factory configuration
- Store
function graphqlStoreFactory(
$store: Store,
selector: MemoizedSelector<any, any>,
dispatch: () => TypedAction<any>,
map: OperatorFunction<any, any>
) {
$store.dispatch(dispatch())
return $store.select(selector)
.pipe(
map
)
}
- Value
function graphqlFactory(): Observable<GraphqlConfig> {
return of ({ endpoint: "http://localhost:3000/graphql "})
}
- Service configuration
- GRAPHQL_CONFIG provider
{
provide: GRAPHQL_CONFIG,
useFactory: ($store: Store) => graphqlStoreFactory(
$store,
configBaseUriSelector,
ConfigActions.init,
map(baseUrl => ({endpoint: `${baseUrl}/graphql`}))
),
deps: [Store]
}
- GraphqlService provider
{
provide: GraphqlService,
useFactory: ($config: Observable<GraphqlConfig>, $http: HttpClient) => new GraphqlService($config, $http),
deps: [GRAPHQL_CONFIG, HttpClient]
}