@@ -105,6 +105,11 @@ export function gqlSubscribable<T>(
105105 const [ key ] = Object . keys ( data ) ;
106106 const { [ key ] : newValue } = data ;
107107 if ( ! isEqual ( value , newValue ) ) {
108+ if ( query . includes ( 'SubPlanRevision' ) ) {
109+ console . log (
110+ `Plan Revision value stuff: ${ JSON . stringify ( value ) } ${ JSON . stringify ( newValue ) } ${ JSON . stringify ( data ) } ` ,
111+ ) ;
112+ }
108113 value = transformer ( newValue ) ;
109114 subscribers . forEach ( ( { next } ) => {
110115 next ( value as T ) ;
@@ -134,6 +139,7 @@ export function gqlSubscribable<T>(
134139 }
135140
136141 function setVariables ( newVariables : QueryVariables ) : void {
142+ console . log ( '????' ) ;
137143 newVariables = { ...variables , ...newVariables } ;
138144
139145 if ( ! isEqual ( variables , newVariables ) ) {
@@ -148,6 +154,9 @@ export function gqlSubscribable<T>(
148154 * These variables could be stores themselves or plain values.
149155 */
150156 function subscribeToVariables ( initialVariables : QueryVariables | null ) : void {
157+ if ( query . includes ( 'SubPlanRevision' ) ) {
158+ console . log ( `PlanRevision SubscribeToVariables: ${ JSON . stringify ( initialVariables ) } ` ) ;
159+ }
151160 variableUnsubscribers . forEach ( variableUnsubscribe => variableUnsubscribe ( ) ) ;
152161 variableUnsubscribers = [ ] ;
153162
@@ -159,7 +168,11 @@ export function gqlSubscribable<T>(
159168 // and resubscribe to the main query with those new variables
160169 const store = variable as Readable < any > ;
161170 const unsubscriber = store . subscribe ( storeValue => {
162- variables = { ...variables , [ name ] : storeValue } ;
171+ if ( query . includes ( 'SubPlanRevision' ) || query . includes ( 'PlanMergeRequestsOutgoing' ) ) {
172+ const shortQuery = query . includes ( 'SubPlanRevision' ) ? 'SubPlanRevision' : 'PlanMergeRequestsOutgoing' ;
173+ console . log ( `SUBSCRIBER: ${ name } , ${ storeValue } -> ${ shortQuery } ` ) ;
174+ }
175+ // variables = { ...variables, [name]: storeValue };
163176 resubscribe ( ) ;
164177 } ) ;
165178 variableUnsubscribers . push ( unsubscriber ) ;
@@ -169,17 +182,24 @@ export function gqlSubscribable<T>(
169182 }
170183
171184 function subscribe ( next : Subscriber < T > ) : Unsubscriber {
172- // If we are in the browser and do not yet have a web socket client
173- // we will create one and subscribe to variables
174- subscribeToVariables ( variables ) ; // should not be harmful if this runs every time subscribe is called
175-
176- // Subscribe within the WS to the GQL query
177- // Note that subscribeToVariables may immediately result in a resubscription if
178- // any of the variables are stores since the stores will call next(value) on
179- // initial subscription. This call below covers the case where no stores are passed
180- // in as variables. If resubscribe is called by subscribeToVariables then the debounce
181- // should take care of the duplication.
182- debouncedClientSubscribe ( ) ;
185+ if ( browser ) {
186+ if ( query . includes ( 'SubPlanRevision' ) || query . includes ( 'PlanMergeRequestsOutgoing' ) ) {
187+ const shortQuery = query . includes ( 'SubPlanRevision' ) ? 'SubPlanRevision' : 'PlanMergeRequestsOutgoing' ;
188+ console . log ( 'RUNNING -> ' , shortQuery ) ;
189+ }
190+
191+ // If we are in the browser and do not yet have a web socket client
192+ // we will create one and subscribe to variables
193+ subscribeToVariables ( variables ) ; // should not be harmful if this runs every time subscribe is called
194+
195+ // Subscribe within the WS to the GQL query
196+ // Note that subscribeToVariables may immediately result in a resubscription if
197+ // any of the variables are stores since the stores will call next(value) on
198+ // initial subscription. This call below covers the case where no stores are passed
199+ // in as variables. If resubscribe is called by subscribeToVariables then the debounce
200+ // should take care of the duplication.
201+ debouncedClientSubscribe ( ) ;
202+ }
183203
184204 const subscriber : Subscription < T > = { next } ;
185205 subscribers . add ( subscriber ) ;
0 commit comments