src/app/data/component/component-store.service.ts
Provides updating, deleting and retrieving components from the backend. Objects like updateComponentMutation are injected and were created by a codegenerator based on the mutation UpdateComponent in the component.graphql file in this folder. The same hold for the other mutation and query objects.
Methods |
constructor(updateComponentMutation: UpdateComponentGQL, deleteComponentMutation: DeleteComponentGQL, getFullComponentQuery: GetComponentGQL, createComponentMutation: CreateComponentGQL, getLabelsQuery: GetComponentLabelsGQL, getBasicComponentQuery: GetBasicComponentGQL, getComponentInterfacesQuery: GetComponentInterfacesGQL)
|
||||||||||||||||||||||||
Parameters :
|
createComponent | ||||||
createComponent(input: CreateComponentInput)
|
||||||
Parameters :
Returns :
Observable<any>
|
deleteComponent | ||||||
deleteComponent(id: string)
|
||||||
Parameters :
Returns :
Observable<any>
|
getBasicComponent | ||||||
getBasicComponent(id: string)
|
||||||
Parameters :
Returns :
Observable<GetBasicComponentQuery>
|
getComponentInterfaces | ||||||
getComponentInterfaces(id: string)
|
||||||
Parameters :
Returns :
Observable<GetComponentInterfacesQuery>
|
getComponentLabels | ||||||
getComponentLabels(id: string)
|
||||||
Parameters :
Returns :
Observable<GetComponentLabelsQuery>
|
getFullComponent | ||||||
getFullComponent(id: string)
|
||||||
Parameters :
Returns :
Observable<GetComponentQuery>
|
updateComponent | ||||||
updateComponent(input: UpdateComponentInput)
|
||||||
Parameters :
Returns :
Observable<any>
|
import {Injectable} from '@angular/core';
import {Observable} from 'rxjs';
import {
CreateComponentGQL,
CreateComponentInput,
DeleteComponentGQL,
DeleteComponentInput,
GetBasicComponentGQL,
GetBasicComponentQuery,
GetComponentGQL,
GetComponentInterfacesGQL,
GetComponentInterfacesQuery,
GetComponentLabelsGQL,
GetComponentLabelsQuery,
GetComponentQuery,
UpdateComponentGQL,
UpdateComponentInput
} from 'src/generated/graphql';
import {map} from 'rxjs/operators';
/**
* Provides updating, deleting and retrieving components from the backend.
* Objects like updateComponentMutation are injected and were created by a codegenerator based on
* the mutation UpdateComponent in the component.graphql file in this folder. The same hold for the
* other mutation and query objects.
*/
@Injectable({
providedIn: 'root'
})
export class ComponentStoreService {
constructor(
private updateComponentMutation: UpdateComponentGQL,
private deleteComponentMutation: DeleteComponentGQL,
private getFullComponentQuery: GetComponentGQL,
private createComponentMutation: CreateComponentGQL,
private getLabelsQuery: GetComponentLabelsGQL,
private getBasicComponentQuery: GetBasicComponentGQL,
private getComponentInterfacesQuery: GetComponentInterfacesGQL
) {}
getComponentLabels(id: string): Observable<GetComponentLabelsQuery> {
return this.getLabelsQuery.fetch({id}).pipe(map(({data}) => data));
}
getBasicComponent(id: string): Observable<GetBasicComponentQuery> {
return this.getBasicComponentQuery.fetch({id}).pipe(map(({data}) => data));
}
getFullComponent(id: string): Observable<GetComponentQuery> {
return this.getFullComponentQuery.fetch({id}).pipe(map(({data}) => data));
}
getComponentInterfaces(id: string): Observable<GetComponentInterfacesQuery> {
return this.getComponentInterfacesQuery.fetch({id}).pipe(map(({data}) => data));
}
deleteComponent(id: string): Observable<any> {
const input: DeleteComponentInput = {
component: id
};
return this.deleteComponentMutation.mutate({input});
}
createComponent(input: CreateComponentInput): Observable<any> {
return this.createComponentMutation.mutate({input});
}
updateComponent(input: UpdateComponentInput): Observable<any> {
return this.updateComponentMutation.mutate({input});
}
}