UNPKG

graphile-test

Version:
31 lines (30 loc) 1.42 kB
import type { DocumentNode, ExecutionResult, GraphQLSchema } from 'graphql'; import type { GraphileConfig } from 'graphile-config'; import { makePgService } from 'postgraphile/adaptors/pg'; import type { Client, Pool } from 'pg'; import type { GetConnectionOpts, GetConnectionResult } from 'pgsql-test'; import type { GetConnectionsInput } from './types'; interface RunGraphQLOptions { input: GetConnectionsInput & GetConnectionOpts; conn: GetConnectionResult; pgPool: Pool; pgService: ReturnType<typeof makePgService>; schema: GraphQLSchema; resolvedPreset: GraphileConfig.ResolvedPreset; authRole: string; query: string | DocumentNode; variables?: Record<string, any>; reqOptions?: Record<string, unknown>; } /** * Execute a GraphQL query in the v5 context using grafast's execute function. * * This replaces the v4 withPostGraphileContext pattern with grafast execution. * Uses execute() with withPgClient to ensure proper connection handling and pgSettings. */ export declare const runGraphQLInContext: <T = ExecutionResult>({ input, conn, schema, resolvedPreset, pgService, authRole, query, variables, reqOptions, }: RunGraphQLOptions) => Promise<T>; /** * Set the PostgreSQL role and session settings on a client connection. */ export declare function setContextOnClient(pgClient: Client, pgSettings: Record<string, string>, role: string): Promise<void>; export {};