@@ -322,6 +322,13 @@ export function collectSpatialRelations(build: any): SpatialRelationInfo[] {
322322 const pgRegistry = build . input ?. pgRegistry ;
323323 if ( ! pgRegistry ) return [ ] ;
324324
325+ // Inflection is used to normalize user-supplied identifiers (the
326+ // parametric arg name, e.g. `travel_distance` → `travelDistance`) into the
327+ // GraphQL casing conventions. Fall back to identity if not available
328+ // (e.g. when invoked from unit tests with a stub build).
329+ const camelCase : ( s : string ) => string =
330+ build . inflection ?. camelCase ?. bind ( build . inflection ) ?? ( ( s : string ) => s ) ;
331+
325332 const relations : SpatialRelationInfo [ ] = [ ] ;
326333
327334 for ( const resource of Object . values ( pgRegistry . pgResources ) as any [ ] ) {
@@ -400,7 +407,7 @@ export function collectSpatialRelations(build: any): SpatialRelationInfo[] {
400407 targetResource : target . resource ,
401408 targetAttributeName : target . attributeName ,
402409 operator : OPERATOR_REGISTRY [ parsed . operator ] ,
403- paramFieldName : parsed . paramName ,
410+ paramFieldName : parsed . paramName ? camelCase ( parsed . paramName ) : null ,
404411 isSelfRelation,
405412 ownerPkAttributes,
406413 targetPkAttributes,
@@ -431,7 +438,10 @@ export function collectSpatialRelations(build: any): SpatialRelationInfo[] {
431438function spatialFilterTypeName ( build : any , rel : SpatialRelationInfo ) : string {
432439 const { inflection } = build ;
433440 const ownerTypeName = inflection . tableType ( rel . ownerCodec ) ;
434- const rel0 = rel . relationName . charAt ( 0 ) . toUpperCase ( ) + rel . relationName . slice ( 1 ) ;
441+ // Normalize the user-supplied relation name (which may be snake_case,
442+ // kebab-case, or mixed) into PascalCase so the type name is consistent
443+ // with every other generated GraphQL type name.
444+ const rel0 = inflection . upperCamelCase ( rel . relationName ) ;
435445 return `${ ownerTypeName } Spatial${ rel0 } Filter` ;
436446}
437447
@@ -638,7 +648,10 @@ export const PostgisSpatialRelationsPlugin: GraphileConfig.Plugin = {
638648 const FilterType = build . getTypeByName ( filterTypeName ) ;
639649 if ( ! FilterType ) continue ;
640650
641- const fieldName = rel . relationName ;
651+ // Normalize the user-supplied relation name (which may be
652+ // snake_case, kebab-case, or mixed) into camelCase so the GraphQL
653+ // field name matches the casing of every other generated field.
654+ const fieldName = inflection . camelCase ( rel . relationName ) ;
642655 // Avoid clobbering fields an upstream plugin may have registered
643656 // (e.g. an FK-derived relation with the same name).
644657 if ( fields [ fieldName ] ) {
0 commit comments