Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | 2x | import { Injectable } from '@angular/core';
import { DialogService } from 'primeng/dynamicdialog';
import { MessageService } from 'primeng/api';
import { Logger } from '@bitblit/ratchet-common/logger/logger';
import { GraphqlRatchet } from '@bitblit/ratchet-graphql/graphql/graphql-ratchet';
import { BlockUiComponent } from "../components/dialogs/block-ui/block-ui.component";
import {AuthorizationStyle} from "@bitblit/ratchet-graphql/graphql/authorization-style";
@Injectable({providedIn: 'root'})
export class GraphqlQueryService {
constructor(
private graphqlRatchet: GraphqlRatchet,
private dialogService: DialogService,
private messageService: MessageService,
) {}
public async executeQuery<T>(queryName: string, variables: any, authStyle: AuthorizationStyle = AuthorizationStyle.TokenRequired
): Promise<T | null> {
let rval: T | null = null;
this.messageService.add({ severity: 'info', summary: 'Running query', detail: queryName, life: 3000 });
Logger.info('eq: %j -: %s --: %s ---: %j', queryName, variables);
try {
rval = await this.graphqlRatchet.executeQuery<T>(queryName, variables, authStyle);
} catch (err) {
Logger.error('Fail : %s', err);
} finally {
this.messageService.clear();
}
return rval;
}
public async executeQueryWithBlock<T>(
blockMessage: string,
queryName: string,
variables: any,
authStyle: AuthorizationStyle = AuthorizationStyle.TokenRequired
): Promise<T | null> {
let rval: T | null = null;
this.messageService.add({ severity: 'info', summary: 'Running query', detail: queryName, life: 3000 });
Logger.info('eqb: %j -: %s --: %s ---: %j', blockMessage, queryName, variables);
try {
rval = await BlockUiComponent.runPromiseWithUiBlock<T>(
this.dialogService,
this.graphqlRatchet.executeQuery<T>(queryName, variables, authStyle),
blockMessage,
);
} catch (err) {
Logger.error('Fail : %s', err);
} finally {
this.messageService.clear();
}
return rval;
}
public async executeMutate<T>(queryName: string, variables: any, authStyle: AuthorizationStyle = AuthorizationStyle.TokenRequired
): Promise<T | null> {
let rval: T | null = null;
this.messageService.add({ severity: 'info', summary: 'Running query', detail: queryName, life: 3000 });
Logger.info('eq: %j -: %s --: %s ---: %j', queryName, variables);
try {
rval = await this.graphqlRatchet.executeMutate<T>(queryName, variables, authStyle);
} catch (err) {
Logger.error('Fail : %s', err);
} finally {
this.messageService.clear();
}
return rval;
}
public async executeMutateWithBlock<T>(
blockMessage: string,
queryName: string,
variables: any,
authStyle: AuthorizationStyle = AuthorizationStyle.TokenRequired
): Promise<T | null> {
let rval: T | null = null;
this.messageService.add({ severity: 'info', summary: 'Running query', detail: queryName, life: 3000 });
try {
rval = await BlockUiComponent.runPromiseWithUiBlock<T>(
this.dialogService,
this.graphqlRatchet.executeMutate<T>(queryName, variables, authStyle),
blockMessage,
);
} catch (err) {
Logger.error('Fail : %s', err);
} finally {
this.messageService.clear();
}
return rval;
}
}
|