@@ -11,13 +11,16 @@ export function addPgTableCondition(
1111 conditionFieldSpecGenerator : (
1212 build : GraphileBuild . Build ,
1313 ) => GrafastInputFieldConfig ,
14+ // DEPRECATED! Use `apply` instead.
1415 conditionGenerator ?: (
1516 value : unknown ,
1617 helpers : {
1718 sql : typeof sql ;
1819 sqlTableAlias : SQL ;
1920 sqlValueWithCodec : typeof sqlValueWithCodec ;
20- build : GraphileBuild . Build ;
21+ // We can't afford to make the entire of build EXPORTABLE, and people
22+ // really ought to move to using the `apply` method, so...
23+ build : ReturnType < typeof pruneBuild > ;
2124 /** @internal We might expose this in future if needed */
2225 condition : PgCondition ;
2326 } ,
@@ -85,21 +88,23 @@ export function addPgTableCondition(
8588 ) ;
8689 }
8790 // build applyPlan
91+ const _build = pruneBuild ( build ) ;
8892 conditionFieldSpec . apply = EXPORTABLE (
89- ( build , conditionGenerator , sql , sqlValueWithCodec ) =>
93+ ( _build , conditionGenerator , sql , sqlValueWithCodec ) =>
9094 function apply ( condition : PgCondition , val ) {
9195 const expression = conditionGenerator ! ( val , {
9296 sql,
9397 sqlTableAlias : condition . alias ,
9498 sqlValueWithCodec,
95- build,
99+ build : _build ,
96100 condition,
97101 } ) ;
98102 if ( expression ) {
99103 condition . where ( expression ) ;
100104 }
101105 } ,
102- [ build , conditionGenerator , sql , sqlValueWithCodec ] ,
106+ [ _build , conditionGenerator , sql , sqlValueWithCodec ] ,
107+ "addPgTableCondition_generator" ,
103108 ) ;
104109 }
105110 const meta = build . _pluginMeta [ displayName ] ! ;
@@ -125,3 +130,23 @@ export function addPgTableCondition(
125130
126131/** @deprecated renamed to addPgTableCondition */
127132export const makeAddPgTableConditionPlugin = addPgTableCondition ;
133+
134+ function pruneBuild ( build : GraphileBuild . Build ) {
135+ const {
136+ sql,
137+ grafast,
138+ graphql,
139+ dataplanPg,
140+ input : { pgRegistry } ,
141+ } = build ;
142+ return EXPORTABLE (
143+ ( dataplanPg , grafast , graphql , pgRegistry , sql ) => ( {
144+ sql,
145+ grafast,
146+ graphql,
147+ dataplanPg,
148+ input : { pgRegistry } ,
149+ } ) ,
150+ [ dataplanPg , grafast , graphql , pgRegistry , sql ] ,
151+ ) ;
152+ }
0 commit comments