src/app/data/interface/interface-store.service.ts
This service provides creation, retrievel, update and deletion of interfaces offered by components. The GQL object are generated by the code generator based on interface.graphql in the same directory as this file.
Methods |
|
constructor(createInterfaceMutation: CreateComponentInterfaceGQL, updateInterfaceMutation: UpdateComponentInterfaceGQL, deleteInterfaceMutation: DeleteComponentInterfaceGQL, getInterfaceQuery: GetInterfaceGQL, getConsumingComponentsQuery: GetConsumingComponentsGQL)
|
||||||||||||||||||
Parameters :
|
Public create |
create(name: string, offeringComponentId: string, description?: string)
|
Returns :
Observable<any>
|
Public delete | ||||||
delete(id: string)
|
||||||
Parameters :
Returns :
Observable<any>
|
Public getConsumingComponents | ||||||
getConsumingComponents(id: string)
|
||||||
Parameters :
Returns :
Observable<GetConsumingComponentsQuery>
|
Public getInterface | ||||||
getInterface(id: string)
|
||||||
Parameters :
Returns :
Observable<GetInterfaceQuery>
|
Public update | ||||||
update(input: UpdateComponentInterfaceInput)
|
||||||
Parameters :
Returns :
Observable<any>
|
import {Injectable} from '@angular/core';
import {
CreateComponentInterfaceGQL,
CreateComponentInterfaceInput,
DeleteComponentInterfaceGQL,
DeleteComponentInterfaceInput,
GetConsumingComponentsGQL,
GetConsumingComponentsQuery,
GetInterfaceGQL,
GetInterfaceQuery,
UpdateComponentInterfaceGQL,
UpdateComponentInterfaceInput
} from '../../../generated/graphql';
import {map} from 'rxjs/operators';
import {Observable} from 'rxjs';
/**
* This service provides creation, retrievel, update and deletion of interfaces offered by components.
* The GQL object are generated by the code generator based on interface.graphql in the same directory
* as this file.
*/
@Injectable({
providedIn: 'root'
})
export class InterfaceStoreService {
constructor(
private createInterfaceMutation: CreateComponentInterfaceGQL,
private updateInterfaceMutation: UpdateComponentInterfaceGQL,
private deleteInterfaceMutation: DeleteComponentInterfaceGQL,
private getInterfaceQuery: GetInterfaceGQL,
private getConsumingComponentsQuery: GetConsumingComponentsGQL
) {}
public create(name: string, offeringComponentId: string, description?: string): Observable<any> {
const input: CreateComponentInterfaceInput = {
name,
description,
component: offeringComponentId
};
return this.createInterfaceMutation.mutate({input});
}
public getInterface(id: string): Observable<GetInterfaceQuery> {
return this.getInterfaceQuery.fetch({id}).pipe(map(({data}) => data));
}
public getConsumingComponents(id: string): Observable<GetConsumingComponentsQuery> {
return this.getConsumingComponentsQuery.fetch({id}).pipe(map(({data}) => data));
}
public update(input: UpdateComponentInterfaceInput): Observable<any> {
return this.updateInterfaceMutation.mutate({input});
}
public delete(id: string): Observable<any> {
const input: DeleteComponentInterfaceInput = {
componentInterface: id
};
return this.deleteInterfaceMutation.mutate({input});
}
}