@@ -292,6 +292,33 @@ describe("InternalModelManager", () => {
292292 expect ( plan . variables ) . toEqual ( { search : "term" } ) ;
293293 } ) ;
294294
295+ test ( "should build a find many query with searchFields" , ( ) => {
296+ const plan = internalFindManyQuery ( "widget" , [ ] , { search : "term" , searchFields : { name : true , state : false , id : { weight : 10 } } } ) ;
297+ expect ( plan . query ) . toMatchInlineSnapshot ( `
298+ "query InternalFindManyWidget($search: String, $searchFields: WidgetSearchFields) {
299+ internal {
300+ listWidget(search: $search, searchFields: $searchFields) {
301+ pageInfo {
302+ hasNextPage
303+ hasPreviousPage
304+ startCursor
305+ endCursor
306+ }
307+ edges {
308+ cursor
309+ node
310+ }
311+ }
312+ }
313+ gadgetMeta {
314+ hydrations(modelName: "widget")
315+ }
316+ }"
317+ ` ) ;
318+ expectValidGraphQLQuery ( plan . query ) ;
319+ expect ( plan . variables ) . toEqual ( { search : "term" , searchFields : { name : { } , id : { weight : 10 } } } ) ;
320+ } ) ;
321+
295322 test ( "should build a find many query with filter" , ( ) => {
296323 const plan = internalFindManyQuery ( "widget" , [ ] , { filter : [ { id : { equals : "1" } } ] } ) ;
297324 expect ( plan . query ) . toMatchInlineSnapshot ( `
@@ -460,6 +487,26 @@ describe("InternalModelManager", () => {
460487 expect ( plan . variables ) . toEqual ( { first : 1 , search : "term" } ) ;
461488 } ) ;
462489
490+ test ( "should build a find first query with searchFields" , ( ) => {
491+ const plan = internalFindFirstQuery ( "widget" , [ ] , { search : "term" , searchFields : { name : true , state : false , id : { weight : 10 } } } ) ;
492+ expect ( plan . query ) . toMatchInlineSnapshot ( `
493+ "query InternalFindFirstWidget($search: String, $searchFields: WidgetSearchFields, $first: Int) {
494+ internal {
495+ listWidget(search: $search, searchFields: $searchFields, first: $first) {
496+ edges {
497+ node
498+ }
499+ }
500+ }
501+ gadgetMeta {
502+ hydrations(modelName: "widget")
503+ }
504+ }"
505+ ` ) ;
506+ expectValidGraphQLQuery ( plan . query ) ;
507+ expect ( plan . variables ) . toEqual ( { first : 1 , search : "term" , searchFields : { name : { } , id : { weight : 10 } } } ) ;
508+ } ) ;
509+
463510 test ( "should build a find first query with filter" , ( ) => {
464511 const plan = internalFindFirstQuery ( "widget" , [ ] , { filter : [ { id : { equals : "1" } } ] } ) ;
465512
@@ -578,6 +625,40 @@ describe("InternalModelManager", () => {
578625 expectValidGraphQLQuery ( plan . query ) ;
579626 } ) ;
580627
628+ test ( "should build a find first query with searchFilter" , ( ) => {
629+ const plan = internalFindFirstQuery ( "widget_model" , [ ] , {
630+ search : "term" ,
631+ searchFields : { name : true , state : false , id : { weight : 10 } } ,
632+ } ) ;
633+ expect ( plan ) . toMatchInlineSnapshot ( `
634+ {
635+ "query": "query InternalFindFirstWidgetModel($search: String, $searchFields: WidgetModelSearchFields, $first: Int) {
636+ internal {
637+ listWidgetModel(search: $search, searchFields: $searchFields, first: $first) {
638+ edges {
639+ node
640+ }
641+ }
642+ }
643+ gadgetMeta {
644+ hydrations(modelName: "widget_model")
645+ }
646+ }",
647+ "variables": {
648+ "first": 1,
649+ "search": "term",
650+ "searchFields": {
651+ "id": {
652+ "weight": 10,
653+ },
654+ "name": {},
655+ },
656+ },
657+ }
658+ ` ) ;
659+ expectValidGraphQLQuery ( plan . query ) ;
660+ } ) ;
661+
581662 test ( "should build a find first query with filter" , ( ) => {
582663 const plan = internalFindFirstQuery ( "widget_model" , [ ] , { filter : [ { id : { equals : "1" } } ] } ) ;
583664 expect ( plan ) . toMatchInlineSnapshot ( `
0 commit comments