remove apollo for now
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {ApolloModule, Apollo} from 'apollo-angular';
|
||||
import {HttpLinkModule, HttpLink} from 'apollo-angular-link-http';
|
||||
import {InMemoryCache} from 'apollo-cache-inmemory';
|
||||
|
||||
@NgModule({
|
||||
exports: [ApolloModule, HttpLinkModule]
|
||||
})
|
||||
export class GraphQLModule {
|
||||
constructor(apollo: Apollo,
|
||||
httpLink: HttpLink)
|
||||
{
|
||||
const cache = new InMemoryCache();
|
||||
|
||||
const endpoint = "https://localhost:5001/graphql";
|
||||
apollo.create({
|
||||
link: httpLink.create({uri: endpoint}),
|
||||
cache,
|
||||
defaultOptions: {
|
||||
query: {
|
||||
fetchPolicy: 'network-only'
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { IGraphQLAdvanceQueryInput, GraphQLDataSourceService } from 'projects/poweredsoft/ngx-data-apollo/src/public-api';
|
||||
import { IQueryCriteria, DataSource } from '@poweredsoft/data';
|
||||
import { of } from 'rxjs';
|
||||
import { Apollo } from 'apollo-angular';
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export interface IValidationTestCommand {
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface ITestModel {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface ITestQuery extends IGraphQLAdvanceQueryInput<ITestModel> {
|
||||
|
||||
}
|
||||
|
||||
export interface IGenerateDatasource<T, TAdvanceQuery extends IGraphQLAdvanceQueryInput<T>> {
|
||||
criteria: IQueryCriteria;
|
||||
beforeReadQueryCriteria?: TAdvanceQuery
|
||||
}
|
||||
|
||||
export interface IGenerateItemDatasource extends IGenerateDatasource<ITestModel, ITestQuery> {
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class TestService {
|
||||
constructor(private graphQLService: GraphQLDataSourceService, private apollo: Apollo) { }
|
||||
|
||||
generateDatasource(options: IGenerateItemDatasource) {
|
||||
const keyResolver = (m: ITestModel) => m.id;
|
||||
let builder = this.graphQLService.createDataSourceOptionsBuilder<ITestModel, string>(
|
||||
"test",
|
||||
"TestQueryInput",
|
||||
[
|
||||
'id'
|
||||
],
|
||||
keyResolver,
|
||||
options.criteria
|
||||
);
|
||||
|
||||
if (options.beforeReadQueryCriteria) {
|
||||
builder.beforeRead<ITestQuery>(query => {
|
||||
return of({ ...query, ...options.beforeReadQueryCriteria });
|
||||
});
|
||||
}
|
||||
|
||||
builder.addMutation<IValidationTestCommand, string>(
|
||||
'validationTest',
|
||||
'validationTest',
|
||||
(command) => {
|
||||
return this.apollo.mutate<string>({
|
||||
mutation:gql`mutation executeValidationTest($command: ValidationTestCommandInput) {
|
||||
validationTest(params: $command)
|
||||
}`,
|
||||
variables: {
|
||||
command: command
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return new DataSource<ITestModel>(builder.create());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user