@@ -893,13 +893,7 @@ describe('collectPayloadTypeNames', () => {
893893// Tests - Plugin-Injected Condition Fields (e.g., VectorSearchPlugin)
894894// ============================================================================
895895
896- describe ( 'plugin-injected condition fields' , ( ) => {
897- /**
898- * Simulates a table with a vector embedding column.
899- * The VectorSearchPlugin adds extra condition fields (e.g., embeddingNearby)
900- * that are NOT derived from the table's own columns, but are injected into
901- * the GraphQL schema's condition type via plugin hooks.
902- */
896+ describe ( 'plugin-injected orderBy values' , ( ) => {
903897 const contactTable = createTable ( {
904898 name : 'Contact' ,
905899 fields : [
@@ -920,151 +914,6 @@ describe('plugin-injected condition fields', () => {
920914 } ,
921915 } ) ;
922916
923- it ( 'includes plugin-injected condition fields from TypeRegistry' , ( ) => {
924- // Registry simulates what PostGraphile + VectorSearchPlugin produce:
925- // The ContactCondition type has the regular columns PLUS an extra
926- // "embeddingNearby" field of type VectorNearbyInput injected by the plugin.
927- const registry = createTypeRegistry ( {
928- ContactCondition : {
929- kind : 'INPUT_OBJECT' ,
930- name : 'ContactCondition' ,
931- inputFields : [
932- { name : 'id' , type : createTypeRef ( 'SCALAR' , 'UUID' ) } ,
933- { name : 'name' , type : createTypeRef ( 'SCALAR' , 'String' ) } ,
934- { name : 'email' , type : createTypeRef ( 'SCALAR' , 'String' ) } ,
935- { name : 'embedding' , type : createTypeRef ( 'SCALAR' , 'Vector' ) } ,
936- {
937- name : 'embeddingNearby' ,
938- type : createTypeRef ( 'INPUT_OBJECT' , 'VectorNearbyInput' ) ,
939- description : 'Find contacts near a vector embedding' ,
940- } ,
941- ] ,
942- } ,
943- VectorNearbyInput : {
944- kind : 'INPUT_OBJECT' ,
945- name : 'VectorNearbyInput' ,
946- inputFields : [
947- {
948- name : 'vector' ,
949- type : createNonNull ( createTypeRef ( 'SCALAR' , 'Vector' ) ) ,
950- } ,
951- {
952- name : 'metric' ,
953- type : createTypeRef ( 'ENUM' , 'VectorMetric' ) ,
954- } ,
955- {
956- name : 'threshold' ,
957- type : createTypeRef ( 'SCALAR' , 'Float' ) ,
958- } ,
959- ] ,
960- } ,
961- VectorMetric : {
962- kind : 'ENUM' ,
963- name : 'VectorMetric' ,
964- enumValues : [ 'L2' , 'INNER_PRODUCT' , 'COSINE' ] ,
965- } ,
966- } ) ;
967-
968- const result = generateInputTypesFile ( registry , new Set ( ) , [ contactTable ] , undefined , true , { condition : true } ) ;
969-
970- // Regular table column fields should still be present
971- expect ( result . content ) . toContain ( 'export interface ContactCondition {' ) ;
972- expect ( result . content ) . toContain ( 'id?: string | null;' ) ;
973- expect ( result . content ) . toContain ( 'name?: string | null;' ) ;
974- expect ( result . content ) . toContain ( 'email?: string | null;' ) ;
975-
976- // Plugin-injected field should also be present
977- expect ( result . content ) . toContain ( 'embeddingNearby?: VectorNearbyInput' ) ;
978-
979- // The referenced VectorNearbyInput type should be generated as a custom input type
980- expect ( result . content ) . toContain ( 'export interface VectorNearbyInput {' ) ;
981-
982- // Transitively referenced enum type (VectorMetric) should also be generated
983- expect ( result . content ) . toContain ( 'VectorMetric' ) ;
984- expect ( result . content ) . toContain ( '"L2"' ) ;
985- expect ( result . content ) . toContain ( '"INNER_PRODUCT"' ) ;
986- expect ( result . content ) . toContain ( '"COSINE"' ) ;
987- } ) ;
988-
989- it ( 'generates transitively referenced enum types from input fields' , ( ) => {
990- // This specifically tests that enum types referenced by input object fields
991- // are followed and generated, not just types ending with "Input".
992- // VectorNearbyInput.metric references VectorMetric (an ENUM),
993- // which must be included in the output.
994- const registry = createTypeRegistry ( {
995- ContactCondition : {
996- kind : 'INPUT_OBJECT' ,
997- name : 'ContactCondition' ,
998- inputFields : [
999- { name : 'id' , type : createTypeRef ( 'SCALAR' , 'UUID' ) } ,
1000- { name : 'name' , type : createTypeRef ( 'SCALAR' , 'String' ) } ,
1001- {
1002- name : 'embeddingNearby' ,
1003- type : createTypeRef ( 'INPUT_OBJECT' , 'VectorNearbyInput' ) ,
1004- } ,
1005- ] ,
1006- } ,
1007- VectorNearbyInput : {
1008- kind : 'INPUT_OBJECT' ,
1009- name : 'VectorNearbyInput' ,
1010- inputFields : [
1011- {
1012- name : 'vector' ,
1013- type : createNonNull ( createTypeRef ( 'SCALAR' , 'Vector' ) ) ,
1014- } ,
1015- {
1016- name : 'metric' ,
1017- type : createTypeRef ( 'ENUM' , 'VectorMetric' ) ,
1018- } ,
1019- ] ,
1020- } ,
1021- VectorMetric : {
1022- kind : 'ENUM' ,
1023- name : 'VectorMetric' ,
1024- enumValues : [ 'L2' , 'INNER_PRODUCT' , 'COSINE' ] ,
1025- } ,
1026- } ) ;
1027-
1028- const result = generateInputTypesFile ( registry , new Set ( ) , [ contactTable ] , undefined , true , { condition : true } ) ;
1029-
1030- // VectorNearbyInput should be generated (follows *Input pattern)
1031- expect ( result . content ) . toContain ( 'export interface VectorNearbyInput {' ) ;
1032-
1033- // VectorMetric enum should ALSO be generated (transitive enum resolution)
1034- expect ( result . content ) . toMatch ( / e x p o r t t y p e V e c t o r M e t r i c \s * = / ) ;
1035- expect ( result . content ) . toContain ( '"L2"' ) ;
1036- expect ( result . content ) . toContain ( '"INNER_PRODUCT"' ) ;
1037- expect ( result . content ) . toContain ( '"COSINE"' ) ;
1038- } ) ;
1039-
1040- it ( 'does not duplicate fields already derived from table columns' , ( ) => {
1041- const registry = createTypeRegistry ( {
1042- ContactCondition : {
1043- kind : 'INPUT_OBJECT' ,
1044- name : 'ContactCondition' ,
1045- inputFields : [
1046- { name : 'id' , type : createTypeRef ( 'SCALAR' , 'UUID' ) } ,
1047- { name : 'name' , type : createTypeRef ( 'SCALAR' , 'String' ) } ,
1048- { name : 'email' , type : createTypeRef ( 'SCALAR' , 'String' ) } ,
1049- { name : 'embedding' , type : createTypeRef ( 'SCALAR' , 'Vector' ) } ,
1050- ] ,
1051- } ,
1052- } ) ;
1053-
1054- const result = generateInputTypesFile ( registry , new Set ( ) , [ contactTable ] , undefined , true , { condition : true } ) ;
1055-
1056- // Count occurrences of 'id?' in the ContactCondition interface
1057- const conditionMatch = result . content . match (
1058- / e x p o r t i n t e r f a c e C o n t a c t C o n d i t i o n \{ ( [ ^ } ] * ) \} / s,
1059- ) ;
1060- expect ( conditionMatch ) . toBeTruthy ( ) ;
1061- const conditionBody = conditionMatch ! [ 1 ] ;
1062-
1063- // Each field should appear only once
1064- const idOccurrences = ( conditionBody . match ( / \b i d \? / g) || [ ] ) . length ;
1065- expect ( idOccurrences ) . toBe ( 1 ) ;
1066- } ) ;
1067-
1068917 it ( 'includes plugin-injected orderBy values from TypeRegistry' , ( ) => {
1069918 const registry = createTypeRegistry ( {
1070919 ContactsOrderBy : {
@@ -1100,15 +949,11 @@ describe('plugin-injected condition fields', () => {
1100949 expect ( result . content ) . toContain ( '"EMBEDDING_DISTANCE_DESC"' ) ;
1101950 } ) ;
1102951
1103- it ( 'works without typeRegistry (backwards compatible)' , ( ) => {
1104- // When no typeRegistry has the condition type, only table columns are used
1105- const result = generateInputTypesFile ( new Map ( ) , new Set ( ) , [ contactTable ] , undefined , true , { condition : true } ) ;
952+ it ( 'does not generate Condition types' , ( ) => {
953+ const result = generateInputTypesFile ( new Map ( ) , new Set ( ) , [ contactTable ] ) ;
1106954
1107- expect ( result . content ) . toContain ( 'export interface ContactCondition {' ) ;
1108- expect ( result . content ) . toContain ( 'id?: string | null;' ) ;
1109- expect ( result . content ) . toContain ( 'name?: string | null;' ) ;
1110- // No plugin-injected fields
1111- expect ( result . content ) . not . toContain ( 'embeddingNearby' ) ;
955+ // Condition types should NOT be generated
956+ expect ( result . content ) . not . toContain ( 'ContactCondition' ) ;
1112957 } ) ;
1113958} ) ;
1114959
0 commit comments