import type { ExecutionResult, GraphQLSchema, DocumentNode } from 'graphql'; import type { GraphileConfig } from 'graphile-config'; import { makePgService } from 'graphile-settings'; import type { Pool } from 'pg'; /** * Settings for creating a GraphQL schema with PostGraphile v5. */ export interface GraphileSettings { /** Database schema(s) to expose */ schema: string | string[]; /** Optional preset to extend the minimal preset */ preset?: GraphileConfig.Preset; /** Function to generate pgSettings from a request object */ pgSettings?: (req: unknown) => Record | Promise>; } /** * Result from getSchema containing the schema and resolved preset. */ export interface SchemaResult { schema: GraphQLSchema; resolvedPreset: GraphileConfig.ResolvedPreset; pgService: ReturnType; } /** * Create a GraphQL schema using PostGraphile v5's preset-based API. * * @param pool - PostgreSQL connection pool * @param settings - Schema configuration including database schemas and optional preset * @returns Promise resolving to schema, resolved preset, and pgService */ export declare const getSchema: (pool: Pool, settings: GraphileSettings) => Promise; /** * Parameters for creating a GraphileQuery instance. */ export interface GraphileQueryParams { schema: GraphQLSchema; pool: Pool; settings: GraphileSettings; resolvedPreset: GraphileConfig.ResolvedPreset; pgService: ReturnType; } /** * Options for executing a GraphQL query. */ export interface QueryOptions { /** Optional request object for pgSettings generation */ req?: unknown; /** GraphQL query string or DocumentNode */ query: string | DocumentNode; /** Query variables */ variables?: Record; /** PostgreSQL role to use for the query */ role?: string; } /** * GraphileQuery provides a way to execute GraphQL queries against a PostGraphile v5 schema. * * This is the full-featured version that supports pgSettings generation from requests. */ export declare class GraphileQuery { private pool; private schema; private settings; private resolvedPreset; private pgService; constructor({ schema, pool, settings, resolvedPreset, pgService }: GraphileQueryParams); /** * Execute a GraphQL query. * * @param options - Query options including query string, variables, and optional role * @returns Promise resolving to the GraphQL execution result */ query({ req, query, variables, role }: QueryOptions): Promise; } /** * Parameters for creating a GraphileQuerySimple instance. */ export interface GraphileQuerySimpleParams { schema: GraphQLSchema; pool: Pool; resolvedPreset: GraphileConfig.ResolvedPreset; pgService: ReturnType; } /** * GraphileQuerySimple provides a simplified way to execute GraphQL queries. * * This version doesn't support pgSettings generation from requests - it's meant * for simple use cases where you just need to run queries. */ export declare class GraphileQuerySimple { private pool; private schema; private resolvedPreset; private pgService; constructor({ schema, pool, resolvedPreset, pgService }: GraphileQuerySimpleParams); /** * Execute a GraphQL query. * * @param query - GraphQL query string or DocumentNode * @param variables - Optional query variables * @returns Promise resolving to the GraphQL execution result */ query(query: string | DocumentNode, variables?: Record): Promise; } /** * Helper function to create a GraphileQuery instance with schema creation. * * This is a convenience function that combines getSchema and GraphileQuery creation. * * @param pool - PostgreSQL connection pool * @param settings - Schema configuration * @returns Promise resolving to a GraphileQuery instance */ export declare const createGraphileQuery: (pool: Pool, settings: GraphileSettings) => Promise; /** * Helper function to create a GraphileQuerySimple instance with schema creation. * * @param pool - PostgreSQL connection pool * @param settings - Schema configuration * @returns Promise resolving to a GraphileQuerySimple instance */ export declare const createGraphileQuerySimple: (pool: Pool, settings: GraphileSettings) => Promise;