@@ -13,6 +13,7 @@ import type { InputTypeComposerFieldConfigAsObjectDefinition } from 'graphql-com
1313
1414import { upperFirst } from '../../utils' ;
1515import type { FilterHelperArgsOpts } from './filter' ;
16+ import GraphQLRegExpAsString from '../../types/RegExpAsString' ;
1617
1718export type FilterOperatorNames =
1819 | 'gt'
@@ -45,28 +46,11 @@ export type FilterOperatorsOpts =
4546
4647export const OPERATORS_FIELDNAME = '_operators' ;
4748
48- export function _createRegexInput ( itc : InputTypeComposer < any > ) : void {
49- itc . schemaComposer . getOrCreateITC ( `${ OPERATORS_FIELDNAME } RegexInput` , ( tc ) => {
50- tc . addFields ( {
51- match : {
52- name : `${ OPERATORS_FIELDNAME } RegexStringInput` ,
53- type : 'String!' ,
54- } ,
55- options : {
56- name : `${ OPERATORS_FIELDNAME } RegexOptionsInput` ,
57- type : 'String' ,
58- } ,
59- } ) ;
60- } ) ;
61- }
62-
6349export function addFilterOperators (
6450 itc : InputTypeComposer < any > ,
6551 model : Model < any > ,
6652 opts : FilterHelperArgsOpts
6753) : void {
68- _createRegexInput ( itc ) ;
69-
7054 if ( ! { } . hasOwnProperty . call ( opts , 'operators' ) || opts . operators !== false ) {
7155 _createOperatorsField (
7256 itc ,
@@ -118,7 +102,7 @@ export function _availableOperatorsFields(
118102 if ( operatorName === 'exists' ) {
119103 fieldType = 'Boolean' ;
120104 } else if ( operatorName === 'regex' ) {
121- fieldType = itc . schemaComposer . getITC ( ` ${ OPERATORS_FIELDNAME } RegexInput` ) ;
105+ fieldType = GraphQLRegExpAsString ;
122106 }
123107 fields [ operatorName ] = {
124108 ...fc ,
@@ -232,8 +216,6 @@ export function _createOperatorsField<TContext>(
232216 operatorsOpts : FilterOperatorsOpts ,
233217 onlyIndexed : boolean = false
234218) : InputTypeComposer < TContext > {
235- _createRegexInput ( itc ) ;
236-
237219 const operatorsITC = itc . schemaComposer . getOrCreateITC ( typeName , ( tc ) => {
238220 tc . setDescription ( 'For performance reason this type contains only *indexed* fields.' ) ;
239221 } ) ;
0 commit comments