data source options builder

This commit is contained in:
David Lebee 2019-12-06 14:33:38 -06:00
parent 44def3a9fc
commit a6e3f0999e

View File

@ -40,6 +40,7 @@ export class GraphQLDataSourceOptionsBuilder<TModel, TKey> {
let ret: IDataSourceQueryAdapterOptions<TModel> = {
adapter: <IAdvanceQueryAdapter<IQueryCriteria, TModel>>{
handle: (query: IQueryCriteria) => {
const advanceQuery = this.createGraphQLQueryCriteria(query);
const o$ = this.apollo.query<any>({
query: this.createGraphQLQuery(query),
@ -47,14 +48,11 @@ export class GraphQLDataSourceOptionsBuilder<TModel, TKey> {
criteria: advanceQuery
}
});
return o$.pipe(
map(result => {
const queryResult = result.data[this.queryName] as IGraphQLAdvanceQueryResult<TModel>;
return this.queryResultFromGraphQLAdvancedResult(query, queryResult);
}),
catchError(err => {
console.error(err);
return err;
})
);
}