-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathaugmentations.ts
More file actions
109 lines (101 loc) · 4.85 KB
/
augmentations.ts
File metadata and controls
109 lines (101 loc) · 4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
* TypeScript namespace augmentations for graphile-connection-filter.
*
* These extend the Graphile type system so that our custom inflection methods,
* build properties, scope properties, schema options, and behaviors are
* recognized by the TypeScript compiler.
*/
import 'graphile-build';
import 'graphile-build-pg';
import type { ConnectionFilterOperatorSpec, ConnectionFilterOperatorsDigest, PgConnectionFilterOperatorsScope } from './types';
declare global {
namespace GraphileBuild {
interface Inflection {
/** Filter type name for a table, e.g. "UserFilter" */
filterType(this: Inflection, typeName: string): string;
/** Filter field type name for a scalar, e.g. "StringFilter" */
filterFieldType(this: Inflection, typeName: string): string;
/** Filter field list type name for an array scalar, e.g. "StringListFilter" */
filterFieldListType(this: Inflection, typeName: string): string;
/** Forward relation field name (passthrough) */
filterSingleRelationFieldName(this: Inflection, fieldName: string): string;
/** Forward relation exists field name, e.g. "clientByClientIdExists" */
filterForwardRelationExistsFieldName(this: Inflection, relationFieldName: string): string;
/** Backward single relation field name (passthrough) */
filterSingleRelationByKeysBackwardsFieldName(this: Inflection, fieldName: string): string;
/** Backward single relation exists field name */
filterBackwardSingleRelationExistsFieldName(this: Inflection, relationFieldName: string): string;
/** Backward many relation field name (passthrough) */
filterManyRelationByKeysFieldName(this: Inflection, fieldName: string): string;
/** Backward many relation exists field name */
filterBackwardManyRelationExistsFieldName(this: Inflection, relationFieldName: string): string;
/** Many filter type name, e.g. "ClientToManyOrderFilter" */
filterManyType(this: Inflection, table: any, foreignTable: any): string;
}
interface Build {
/** Returns the operator digest for a given codec, or null if not filterable */
connectionFilterOperatorsDigest(codec: any): ConnectionFilterOperatorsDigest | null;
/** Escapes LIKE wildcard characters (% and _) */
escapeLikeWildcards(input: unknown): string;
/** Registers a custom filter operator (used by satellite plugins) */
addConnectionFilterOperator(
typeNameOrNames: string | string[],
filterName: string,
spec: ConnectionFilterOperatorSpec
): void;
/** Internal filter operator registry keyed by filter type name */
[key: symbol]: any;
}
interface ScopeInputObject {
/** True if this is a table-level connection filter type (e.g. UserFilter) */
isPgConnectionFilter?: boolean;
// pgCodec is already declared by graphile-build-pg on ScopeInputObject
/** Operator type scope data (present on scalar filter types like StringFilter) */
pgConnectionFilterOperators?: PgConnectionFilterOperatorsScope;
/** Foreign table resource (used by many filter types) */
foreignTable?: any;
/** True if this is a many-relation filter type (e.g. ClientToManyOrderFilter) */
isPgConnectionFilterMany?: boolean;
}
interface ScopeInputObjectFieldsField {
/** True if this field is an attribute-based filter field */
isPgConnectionFilterField?: boolean;
/** True if this field is a filter operator (e.g. equalTo, lessThan) */
isPgConnectionFilterOperator?: boolean;
/** True if this field is a logical operator (and/or/not) */
isPgConnectionFilterOperatorLogical?: boolean;
/** True if this is a many-relation filter field */
isPgConnectionFilterManyField?: boolean;
}
interface BehaviorStrings {
filter: true;
filterProc: true;
'attribute:filterBy': true;
}
interface SchemaOptions {
connectionFilterArrays?: boolean;
connectionFilterLogicalOperators?: boolean;
connectionFilterAllowNullInput?: boolean;
connectionFilterAllowedFieldTypes?: string[];
connectionFilterAllowedOperators?: string[];
connectionFilterOperatorNames?: Record<string, string>;
connectionFilterSetofFunctions?: boolean;
connectionFilterComputedColumns?: boolean;
connectionFilterRelations?: boolean;
}
}
namespace GraphileConfig {
interface Plugins {
ConnectionFilterInflectionPlugin: true;
ConnectionFilterTypesPlugin: true;
ConnectionFilterArgPlugin: true;
ConnectionFilterAttributesPlugin: true;
ConnectionFilterOperatorsPlugin: true;
ConnectionFilterCustomOperatorsPlugin: true;
ConnectionFilterLogicalOperatorsPlugin: true;
ConnectionFilterComputedAttributesPlugin: true;
ConnectionFilterForwardRelationsPlugin: true;
ConnectionFilterBackwardRelationsPlugin: true;
}
}
}