advancing well

This commit is contained in:
David Lebee
2019-12-06 12:41:28 -06:00
parent c1d56d0c19
commit 0adaa73439
18 changed files with 653 additions and 74 deletions
+4
View File
@@ -4,4 +4,8 @@
<button (click)="onDelete()">
Delete
</button>
<button (click)="testGraphQL()">
Test GraphQL query
</button>
+34 -1
View File
@@ -2,6 +2,14 @@ import { Component, OnInit } from '@angular/core';
import { GenericRestDataSourceService } from 'projects/poweredsoft/ngx-data/src/public-api';
import { of } from 'rxjs';
import { DataSource } from '@poweredsoft/data';
import { GraphQLDataSourceService } from 'projects/poweredsoft/ngx-data-apollo/src/public-api';
export interface IContact {
id: number;
firstName :string;
lastName: string;
}
export interface ICustomerModel {
id: number;
@@ -18,7 +26,7 @@ export class AppComponent implements OnInit {
title = 'ngx-data';
dataSource: DataSource<ICustomerModel>;
constructor(genericService: GenericRestDataSourceService) {
constructor(genericService: GenericRestDataSourceService, private graphQLService: GraphQLDataSourceService) {
const keyResolver = (model: ICustomerModel) => model.id;
const transportOptions = genericService.createStandardRestTransportOptions('api/customer', keyResolver);
@@ -68,4 +76,29 @@ export class AppComponent implements OnInit {
//console.log(error);
});
}
testGraphQL() {
const builder = this.graphQLService.createDataSourceOptionsBuilder<IContact, number>(
'contacts',
'GraphQLAdvanceQueryOfContactModelInput',
'id firstName lastName',
(m) => m.id,
{
aggregates: [
{
path: 'id',
type: 'Max'
}
]
}
);
const dataSourceOptions = builder.create();
const dataSource = new DataSource<IContact>(dataSourceOptions);
const subscription = dataSource.data$.subscribe(contacts => {
console.log(contacts);
});
dataSource.refresh();
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ import {ApolloModule, APOLLO_OPTIONS} from 'apollo-angular';
import {HttpLinkModule, HttpLink} from 'apollo-angular-link-http';
import {InMemoryCache} from 'apollo-cache-inmemory';
const uri = ''; // <-- add the URL of the GraphQL server here
const uri = 'https://localhost:5001/graphql'; // <-- add the URL of the GraphQL server here
export function createApollo(httpLink: HttpLink) {
return {
link: httpLink.create({uri}),