import { inject, Injectable } from '@angular/core'; import { GitGateway, GitIntegration } from '@task-stream/web/tracker/domain'; import { map, Observable } from 'rxjs'; import { DisableGitIntegrationDocument, EnableGitIntegrationDocument, GitIntegrationDocument, } from '../graphql/generated'; import { GraphqlOperations } from './graphql-operations'; @Injectable() export class GraphqlGitGateway extends GitGateway { private readonly gql = inject(GraphqlOperations); integration(projectId: string): Observable { return this.gql .query(GitIntegrationDocument, { projectId }) .pipe(map((d) => d.gitIntegration)); } enable(projectId: string): Observable { return this.gql .mutate(EnableGitIntegrationDocument, { projectId }) .pipe(map((d) => d.enableGitIntegration)); } disable(projectId: string): Observable { return this.gql .mutate(DisableGitIntegrationDocument, { projectId }) .pipe(map(() => undefined)); } }