mirror of
https://github.com/graphql-hive/console
synced 2026-04-21 14:37:17 +00:00
Use 2 replicas of GraphQL API and make slonik interceptor type-safe (#360)
* type-safe slonik interceptor * Use 2 replicas of graphql-api
This commit is contained in:
parent
bce8aa2c16
commit
80d971f24d
4 changed files with 21 additions and 7 deletions
7
.vscode/extensions.json
vendored
7
.vscode/extensions.json
vendored
|
|
@ -1,3 +1,8 @@
|
|||
{
|
||||
"recommendations": ["fabiospampinato.vscode-terminals", "fabiospampinato.vscode-commands", "esbenp.prettier-vscode"]
|
||||
"recommendations": [
|
||||
"fabiospampinato.vscode-terminals",
|
||||
"fabiospampinato.vscode-commands",
|
||||
"esbenp.prettier-vscode",
|
||||
"thebearingedge.vscode-sql-lit"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ export function deployGraphQL({
|
|||
'graphql-api',
|
||||
{
|
||||
storageContainer,
|
||||
replicas: 1,
|
||||
replicas: 2,
|
||||
readinessProbe: '/_readiness',
|
||||
livenessProbe: '/_health',
|
||||
env: {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,15 @@
|
|||
/// <reference path="../module.d.ts" />
|
||||
import { createPool, TaggedTemplateLiteralInvocation, QueryResultRowColumn, CommonQueryMethods } from 'slonik';
|
||||
import {
|
||||
createPool,
|
||||
TaggedTemplateLiteralInvocation,
|
||||
QueryResultRowColumn,
|
||||
CommonQueryMethods,
|
||||
Interceptor,
|
||||
QueryResultRow,
|
||||
} from 'slonik';
|
||||
import { createQueryLoggingInterceptor } from 'slonik-interceptor-query-logging';
|
||||
import { createSentryInterceptor } from './sentry';
|
||||
|
||||
const dbInterceptors = [createQueryLoggingInterceptor(), createSentryInterceptor()];
|
||||
const dbInterceptors: Interceptor[] = [createQueryLoggingInterceptor(), createSentryInterceptor()];
|
||||
|
||||
export async function getPool(connection: string) {
|
||||
const pool = await createPool(connection, {
|
||||
|
|
@ -14,7 +20,11 @@ export async function getPool(connection: string) {
|
|||
function interceptError<K extends Exclude<keyof CommonQueryMethods, 'transaction'>>(methodName: K) {
|
||||
const original: CommonQueryMethods[K] = pool[methodName];
|
||||
|
||||
function interceptor<T>(this: any, sql: TaggedTemplateLiteralInvocation<T>, values?: QueryResultRowColumn[]): any {
|
||||
function interceptor<T extends QueryResultRow>(
|
||||
this: any,
|
||||
sql: TaggedTemplateLiteralInvocation<T>,
|
||||
values?: QueryResultRowColumn[]
|
||||
): any {
|
||||
return (original as any).call(this, sql, values).catch((error: any) => {
|
||||
error.sql = sql.sql;
|
||||
error.values = sql.values || values;
|
||||
|
|
|
|||
1
packages/services/storage/src/module.d.ts
vendored
1
packages/services/storage/src/module.d.ts
vendored
|
|
@ -1 +0,0 @@
|
|||
declare module 'slonik-interceptor-query-logging';
|
||||
Loading…
Reference in a new issue