@@ -16,7 +16,7 @@ import {
1616 TypeDefinitionNode ,
1717 valueFromAST
1818} from 'graphql' ;
19- import { ModelValidationOptions } from '../config/interfaces' ;
19+ import { ModelOptions } from '../config/interfaces' ;
2020import {
2121 ParsedGraphQLProjectSource ,
2222 ParsedObjectProjectSource ,
@@ -115,16 +115,16 @@ import { parseI18nConfigs } from './parse-i18n';
115115import { parseTTLConfigs } from './parse-ttl' ;
116116import { ValidationContext , ValidationMessage } from './validation' ;
117117
118- export function createModel ( parsedProject : ParsedProject , modelValidationOptions ?: ModelValidationOptions ) : Model {
118+ export function createModel ( parsedProject : ParsedProject , options ?: ModelOptions ) : Model {
119119 const validationContext = new ValidationContext ( ) ;
120120 return new Model ( {
121- types : createTypeInputs ( parsedProject , validationContext ) ,
121+ types : createTypeInputs ( parsedProject , validationContext , options ?? { } ) ,
122122 permissionProfiles : extractPermissionProfiles ( parsedProject ) ,
123123 i18n : extractI18n ( parsedProject ) ,
124124 validationMessages : validationContext . validationMessages ,
125125 billing : extractBilling ( parsedProject ) ,
126- modelValidationOptions ,
127- timeToLiveConfigs : extractTimeToLive ( parsedProject )
126+ timeToLiveConfigs : extractTimeToLive ( parsedProject ) ,
127+ options
128128 } ) ;
129129}
130130
@@ -144,7 +144,11 @@ const VALIDATION_ERROR_MISSING_OBJECT_TYPE_DIRECTIVE = `Add one of @${ROOT_ENTIT
144144const VALIDATION_ERROR_INVALID_DEFINITION_KIND =
145145 'This kind of definition is not allowed. Only object and enum type definitions are allowed.' ;
146146
147- function createTypeInputs ( parsedProject : ParsedProject , context : ValidationContext ) : ReadonlyArray < TypeConfig > {
147+ function createTypeInputs (
148+ parsedProject : ParsedProject ,
149+ context : ValidationContext ,
150+ options : ModelOptions
151+ ) : ReadonlyArray < TypeConfig > {
148152 const graphQLSchemaParts = parsedProject . sources . filter (
149153 parsedSource => parsedSource . kind === ParsedProjectSourceBaseKind . GRAPHQL
150154 ) as ReadonlyArray < ParsedGraphQLProjectSource > ;
@@ -173,7 +177,7 @@ function createTypeInputs(parsedProject: ParsedProject, context: ValidationConte
173177 } ;
174178 return enumTypeInput ;
175179 case OBJECT_TYPE_DEFINITION :
176- return createObjectTypeInput ( definition , schemaPart , context ) ;
180+ return createObjectTypeInput ( definition , schemaPart , context , options ) ;
177181 default :
178182 return undefined ;
179183 }
@@ -196,15 +200,16 @@ function createEnumValues(valueNodes: ReadonlyArray<EnumValueDefinitionNode>): R
196200function createObjectTypeInput (
197201 definition : ObjectTypeDefinitionNode ,
198202 schemaPart : ParsedGraphQLProjectSource ,
199- context : ValidationContext
203+ context : ValidationContext ,
204+ options : ModelOptions
200205) : ObjectTypeConfig {
201206 const entityType = getKindOfObjectTypeNode ( definition , context ) ;
202207
203208 const common = {
204209 name : definition . name . value ,
205210 description : definition . description ? definition . description . value : undefined ,
206211 astNode : definition ,
207- fields : ( definition . fields || [ ] ) . map ( field => createFieldInput ( field , context ) ) ,
212+ fields : ( definition . fields || [ ] ) . map ( field => createFieldInput ( field , context , options ) ) ,
208213 namespacePath : getNamespacePath ( definition , schemaPart . namespacePath ) ,
209214 flexSearchLanguage : getDefaultLanguage ( definition , context )
210215 } ;
@@ -457,7 +462,11 @@ function getLanguage(fieldNode: FieldDefinitionNode, context: ValidationContext)
457462 }
458463}
459464
460- function createFieldInput ( fieldNode : FieldDefinitionNode , context : ValidationContext ) : FieldConfig {
465+ function createFieldInput (
466+ fieldNode : FieldDefinitionNode ,
467+ context : ValidationContext ,
468+ options : ModelOptions
469+ ) : FieldConfig {
461470 const inverseOfASTNode = getInverseOfASTNode ( fieldNode , context ) ;
462471 const relationDeleteActionASTNode = getRelationDeleteActionASTNode ( fieldNode , context ) ;
463472 const referenceDirectiveASTNode = findDirectiveWithName ( fieldNode , REFERENCE_DIRECTIVE ) ;
@@ -500,7 +509,7 @@ function createFieldInput(fieldNode: FieldDefinitionNode, context: ValidationCon
500509 isFlexSearchIndexCaseSensitive :
501510 flexSearchIndexCaseSensitiveNode ?. value . kind === 'BooleanValue'
502511 ? flexSearchIndexCaseSensitiveNode . value . value
503- : undefined ,
512+ : options . isFlexSearchIndexCaseSensitiveByDefault ,
504513 isFlexSearchIndexedASTNode : findDirectiveWithName ( fieldNode , FLEX_SEARCH_INDEXED_DIRECTIVE ) ,
505514 isFlexSearchFulltextIndexed : hasDirectiveWithName ( fieldNode , FLEX_SEARCH_FULLTEXT_INDEXED_DIRECTIVE ) ,
506515 isFlexSearchFulltextIndexedASTNode : findDirectiveWithName ( fieldNode , FLEX_SEARCH_FULLTEXT_INDEXED_DIRECTIVE ) ,
0 commit comments