UNPKG

graphile-search-plugin

Version:

Generate search conditions for your tsvector columns (PostGraphile v5)

30 lines (29 loc) 1.18 kB
/** * TsvectorCodecPlugin * * Teaches PostGraphile v5 how to handle PostgreSQL's tsvector and tsquery types. * Without this, tsvector columns are invisible to the schema builder and the * search plugin cannot generate condition fields. * * This plugin: * 1. Creates codecs for tsvector/tsquery via gather.hooks.pgCodecs_findPgCodec * 2. Registers a custom "FullText" scalar type for tsvector columns * 3. Maps tsvector codec to the FullText scalar (isolating filter operators) * 4. Maps tsquery codec to GraphQL String * 5. Optionally hides tsvector columns from output types */ import type { GraphileConfig } from 'graphile-config'; import type { PgSearchPluginOptions } from './types'; /** * Creates a TsvectorCodecPlugin with the given options. * * @param options - Plugin configuration * @returns GraphileConfig.Plugin */ export declare function createTsvectorCodecPlugin(options?: PgSearchPluginOptions): GraphileConfig.Plugin; /** * Default static instance using default options. * Maps tsvector to the "FullText" scalar. */ export declare const TsvectorCodecPlugin: GraphileConfig.Plugin; export declare const TsvectorCodecPreset: GraphileConfig.Preset;