@@ -174,6 +174,23 @@ export default (function PgBackwardRelationPlugin(
174174 table . primaryKeyConstraint
175175 ) {
176176 innerQueryBuilder . selectIdentifiers ( table ) ;
177+ innerQueryBuilder . makeLiveCollection ( table ) ;
178+ innerQueryBuilder . addLiveCondition (
179+ data => record => {
180+ return keys . every (
181+ key =>
182+ record [ key . name ] === data [ key . name ]
183+ ) ;
184+ } ,
185+ keys . reduce ( ( memo , key , i ) => {
186+ memo [
187+ key . name
188+ ] = sql . fragment `${ foreignTableAlias } .${ sql . identifier (
189+ foreignKeys [ i ] . name
190+ ) } `;
191+ return memo ;
192+ } , { } )
193+ ) ;
177194 }
178195 keys . forEach ( ( key , i ) => {
179196 innerQueryBuilder . where (
@@ -207,6 +224,24 @@ export default (function PgBackwardRelationPlugin(
207224 const liveRecord =
208225 resolveInfo . rootValue &&
209226 resolveInfo . rootValue . liveRecord ;
227+ const liveCollection =
228+ resolveInfo . rootValue &&
229+ resolveInfo . rootValue . liveCollection ;
230+ const liveConditions =
231+ resolveInfo . rootValue &&
232+ resolveInfo . rootValue . liveConditions ;
233+ if (
234+ subscriptions &&
235+ liveCollection &&
236+ liveConditions &&
237+ data . __live
238+ ) {
239+ const { __id, ...rest } = data . __live ;
240+ const condition = liveConditions [ __id ] ;
241+ const checker = condition ( rest ) ;
242+
243+ liveCollection ( "pg" , table , checker ) ;
244+ }
210245 if ( record && liveRecord ) {
211246 liveRecord ( "pg" , table , record . __identifiers ) ;
212247 }
0 commit comments