graphile-settings
Version:
graphile settings
42 lines (41 loc) • 1.33 kB
TypeScript
import type { GraphileConfig } from 'graphile-config';
/**
* Type mapping configuration for custom PostgreSQL types.
*/
export interface TypeMapping {
/** PostgreSQL type name */
name: string;
/** PostgreSQL schema/namespace name */
namespaceName: string;
/** GraphQL type to map to */
type: 'String';
}
/**
* Plugin that maps custom PostgreSQL types to GraphQL scalar types.
*
* This is useful for domain types or composite types that should be
* represented as simple scalars (String, JSON) in the GraphQL API.
*
* For example, if you have:
* CREATE DOMAIN email AS text;
* CREATE TYPE url AS (value text);
*
* This plugin will map them to GraphQL String type instead of creating
* complex object types.
*
* The plugin handles both:
* 1. Domain types (simple aliases) - maps directly to the target scalar
* 2. Composite types - extracts the first field's value when converting from PG
*/
export declare const PgTypeMappingsPlugin: GraphileConfig.Plugin;
/**
* Preset that includes the PG type mappings plugin.
*
* This preset maps common custom PostgreSQL types to GraphQL scalars:
* - email -> String
* - hostname -> String
* - url -> String
* - origin -> String
*/
export declare const PgTypeMappingsPreset: GraphileConfig.Preset;
export default PgTypeMappingsPlugin;