@@ -193,12 +193,7 @@ function useInternalState<
193
193
( renderPromises &&
194
194
renderPromises . getSSRObservable ( makeWatchQueryOptions ( ) ) ) ||
195
195
client . watchQuery (
196
- getObsQueryOptions (
197
- undefined ,
198
- client ,
199
- options ,
200
- makeWatchQueryOptions ( )
201
- )
196
+ getObsQueryOptions ( void 0 , client , options , makeWatchQueryOptions ( ) )
202
197
) ,
203
198
resultData : {
204
199
// Reuse previousData from previous InternalState (if any) to provide
@@ -267,7 +262,7 @@ export function useQueryInternals<
267
262
const renderPromises = React . useContext ( getApolloContext ( ) ) . renderPromises ;
268
263
const isSyncSSR = ! ! renderPromises ;
269
264
const disableNetworkFetches = client . disableNetworkFetches ;
270
- const ssrAllowed = ! ( options . ssr === false || options . skip ) ;
265
+ const ssrAllowed = options . ssr !== false && ! options . skip ;
271
266
const partialRefetch = options . partialRefetch ;
272
267
273
268
const makeWatchQueryOptions = createMakeWatchQueryOptions (
@@ -310,11 +305,7 @@ export function useQueryInternals<
310
305
isSyncSSR
311
306
) ;
312
307
313
- useRegisterSSRObservable < TData , TVariables > (
314
- observable ,
315
- renderPromises ,
316
- ssrAllowed
317
- ) ;
308
+ useRegisterSSRObservable ( observable , renderPromises , ssrAllowed ) ;
318
309
319
310
const result = useObservableSubscriptionResult < TData , TVariables > (
320
311
resultData ,
@@ -349,7 +340,6 @@ function useObservableSubscriptionResult<
349
340
disableNetworkFetches : boolean ,
350
341
partialRefetch : boolean | undefined ,
351
342
skipSubscribing : boolean ,
352
-
353
343
callbacks : {
354
344
onCompleted : ( data : TData ) => void ;
355
345
onError : ( error : ApolloError ) => void ;
@@ -483,11 +473,8 @@ function useObservableSubscriptionResult<
483
473
) ;
484
474
}
485
475
486
- function useRegisterSSRObservable <
487
- TData = any ,
488
- TVariables extends OperationVariables = OperationVariables ,
489
- > (
490
- observable : ObsQueryWithMeta < TData , TVariables > ,
476
+ function useRegisterSSRObservable (
477
+ observable : ObsQueryWithMeta < any , any > ,
491
478
renderPromises : RenderPromises | undefined ,
492
479
ssrAllowed : boolean
493
480
) {
@@ -569,32 +556,30 @@ function useResubscribeIfNecessary<
569
556
options : QueryHookOptions < NoInfer < TData > , NoInfer < TVariables > > ,
570
557
watchQueryOptions : Readonly < WatchQueryOptions < TVariables , TData > >
571
558
) {
572
- {
573
- if (
574
- observable [ lastWatchOptions ] &&
575
- ! equal ( observable [ lastWatchOptions ] , watchQueryOptions )
576
- ) {
577
- // Though it might be tempting to postpone this reobserve call to the
578
- // useEffect block, we need getCurrentResult to return an appropriate
579
- // loading:true result synchronously (later within the same call to
580
- // useQuery). Since we already have this.observable here (not true for
581
- // the very first call to useQuery), we are not initiating any new
582
- // subscriptions, though it does feel less than ideal that reobserve
583
- // (potentially) kicks off a network request (for example, when the
584
- // variables have changed), which is technically a side-effect.
585
- observable . reobserve (
586
- getObsQueryOptions ( observable , client , options , watchQueryOptions )
587
- ) ;
588
-
589
- // Make sure getCurrentResult returns a fresh ApolloQueryResult<TData>,
590
- // but save the current data as this.previousData, just like setResult
591
- // usually does.
592
- resultData . previousData =
593
- resultData . current ?. data || resultData . previousData ;
594
- resultData . current = void 0 ;
595
- }
596
- observable [ lastWatchOptions ] = watchQueryOptions ;
559
+ if (
560
+ observable [ lastWatchOptions ] &&
561
+ ! equal ( observable [ lastWatchOptions ] , watchQueryOptions )
562
+ ) {
563
+ // Though it might be tempting to postpone this reobserve call to the
564
+ // useEffect block, we need getCurrentResult to return an appropriate
565
+ // loading:true result synchronously (later within the same call to
566
+ // useQuery). Since we already have this.observable here (not true for
567
+ // the very first call to useQuery), we are not initiating any new
568
+ // subscriptions, though it does feel less than ideal that reobserve
569
+ // (potentially) kicks off a network request (for example, when the
570
+ // variables have changed), which is technically a side-effect.
571
+ observable . reobserve (
572
+ getObsQueryOptions ( observable , client , options , watchQueryOptions )
573
+ ) ;
574
+
575
+ // Make sure getCurrentResult returns a fresh ApolloQueryResult<TData>,
576
+ // but save the current data as this.previousData, just like setResult
577
+ // usually does.
578
+ resultData . previousData =
579
+ resultData . current ?. data || resultData . previousData ;
580
+ resultData . current = void 0 ;
597
581
}
582
+ observable [ lastWatchOptions ] = watchQueryOptions ;
598
583
}
599
584
600
585
/*
@@ -724,7 +709,7 @@ function setResult<TData, TVariables extends OperationVariables>(
724
709
) ;
725
710
}
726
711
727
- function handleErrorOrCompleted < TData , TVariables extends OperationVariables > (
712
+ function handleErrorOrCompleted < TData > (
728
713
result : ApolloQueryResult < TData > ,
729
714
previousResult : ApolloQueryResult < TData > | undefined ,
730
715
callbacks : Callbacks < TData >
0 commit comments