File

src/app/data/interface/interface-store.service.ts

Description

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.

Index

Methods

Constructor

constructor(createInterfaceMutation: CreateComponentInterfaceGQL, updateInterfaceMutation: UpdateComponentInterfaceGQL, deleteInterfaceMutation: DeleteComponentInterfaceGQL, getInterfaceQuery: GetInterfaceGQL, getConsumingComponentsQuery: GetConsumingComponentsGQL)
Parameters :
Name Type Optional
createInterfaceMutation CreateComponentInterfaceGQL No
updateInterfaceMutation UpdateComponentInterfaceGQL No
deleteInterfaceMutation DeleteComponentInterfaceGQL No
getInterfaceQuery GetInterfaceGQL No
getConsumingComponentsQuery GetConsumingComponentsGQL No

Methods

Public create
create(name: string, offeringComponentId: string, description?: string)
Parameters :
Name Type Optional
name string No
offeringComponentId string No
description string Yes
Returns : Observable<any>
Public delete
delete(id: string)
Parameters :
Name Type Optional
id string No
Returns : Observable<any>
Public getConsumingComponents
getConsumingComponents(id: string)
Parameters :
Name Type Optional
id string No
Returns : Observable<GetConsumingComponentsQuery>
Public getInterface
getInterface(id: string)
Parameters :
Name Type Optional
id string No
Returns : Observable<GetInterfaceQuery>
Public update
update(input: UpdateComponentInterfaceInput)
Parameters :
Name Type Optional
input UpdateComponentInterfaceInput No
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});
  }
}

results matching ""

    No results matching ""