UNPKG

@graphql-hive/core

Version:
79 lines 2.25 kB
import { DocumentNode, GraphQLSchema, type ExecutionArgs } from 'graphql'; import type { AbortAction, CollectUsageCallback, GraphQLErrorsResult, HivePluginOptions } from './types.cjs'; interface UsageCollector { collect(): CollectUsageCallback; /** collect a short lived GraphQL request (mutation/query operation) */ collectRequest(args: { args: ExecutionArgs; result: GraphQLErrorsResult | AbortAction; /** duration in milliseconds */ duration: number; experimental__persistedDocumentHash?: string; }): void; /** collect a long-lived GraphQL request/subscription (subscription operation) */ collectSubscription(args: { args: ExecutionArgs; experimental__persistedDocumentHash?: string; }): void; dispose(): Promise<void>; } export declare function createUsage(pluginOptions: HivePluginOptions): UsageCollector; interface CacheResult { document: string; fields: string[]; } export declare function createCollector({ schema, max, ttl, processVariables, }: { schema: GraphQLSchema; max?: number; ttl?: number; processVariables?: boolean; }): (arg: DocumentNode, arg2: { [key: string]: unknown; } | null) => Promise<{ key: string; value: CacheResult; cacheHit: boolean; }>; export interface Report { size: number; map: OperationMap; operations?: RequestOperation[]; subscriptionOperations?: SubscriptionOperation[]; } interface RequestOperation { operationMapKey: string; timestamp: number; execution: { ok: boolean; duration: number; errorsTotal: number; }; persistedDocumentHash?: string; metadata?: { client?: { name: string; version: string; }; }; } interface SubscriptionOperation { operationMapKey: string; timestamp: number; persistedDocumentHash?: string; metadata?: { client?: { name: string; version: string; }; }; } interface OperationMapRecord { operation: string; operationName?: string | null; fields: string[]; } interface OperationMap { [key: string]: OperationMapRecord; } export {}; //# sourceMappingURL=usage.d.ts.map