UNPKG

graphql-compose-mongoose

Version:

Plugin for `graphql-compose` which derive a graphql types from a mongoose model.

32 lines 2 kB
import type { Model } from 'mongoose'; import { InputTypeComposer } from 'graphql-compose'; import type { InputTypeComposerFieldConfigAsObjectDefinition } from 'graphql-compose'; import type { FilterHelperArgsOpts } from './filter'; export declare const availableOperators: readonly ["gt", "gte", "lt", "lte", "ne", "in", "nin", "regex", "exists"]; export type AllowedOperatorsName = (typeof availableOperators)[number]; export type FieldsOperatorsConfig = { [fieldName: string]: FieldsOperatorsConfig | AllowedOperatorsName[] | boolean; } | boolean; export declare const OPERATORS_FIELDNAME = "_operators"; export declare function addFilterOperators(itc: InputTypeComposer<any>, model: Model<any>, opts: FilterHelperArgsOpts): void; export declare function _availableOperatorsFields(fieldName: string, itc: InputTypeComposer, useOperators: AllowedOperatorsName[] | undefined | true): Record<string, InputTypeComposerFieldConfigAsObjectDefinition>; export type OperatorsConfig = { [k: string]: OperatorsConfig | string[]; }; export declare function _recurseSchema(inputITC: InputTypeComposer, sourceITC: InputTypeComposer<any>, opts: CreateOperatorsFieldOpts, indexedFields: string[], pathName: string | null): void; interface CreateOperatorsFieldOpts { baseTypeName: string; operators?: FieldsOperatorsConfig; onlyIndexed?: boolean; prefix?: string; suffix?: string; } export declare function _createOperatorsField<TContext>(itc: InputTypeComposer<TContext>, model: Model<any>, opts: CreateOperatorsFieldOpts): InputTypeComposer<TContext>; export type SelectorOptions = { [k: string]: SelectorOptions | string | string[] | RegExp; }; export declare function _recurseFields(fields: SelectorOptions): SelectorOptions; export declare function processFilterOperators(filter: Record<string, any>): SelectorOptions; export declare function _prepareAndOrFilter(filter: Record<'OR' | 'AND' | '$or' | '$and', any>): void; export {}; //# sourceMappingURL=filterOperators.d.ts.map