Skip to content

Commit 707c91e

Browse files
committed
fix(typescript-react-apollo): fix the type returned by useSuspenseQuery
1 parent 74da8bf commit 707c91e

21 files changed

+834
-94
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-codegen/typescript-react-apollo': patch
3+
---
4+
5+
fix return type of useSuspenseQuery

dev-test/githunt/types.reactApollo.customSuffix.tsx

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -500,13 +500,26 @@ export function useCommentLazyQuery(
500500
options,
501501
);
502502
}
503+
export function useCommentSuspenseQuery(
504+
baseOptions?: Apollo.SuspenseQueryHookOptions<CommentQueryMyOperation, CommentQueryVariables>,
505+
): Apollo.UseSuspenseQueryResult<CommentQueryMyOperation, CommentQueryVariables>;
506+
export function useCommentSuspenseQuery(
507+
baseOptions?:
508+
| Apollo.SkipToken
509+
| Apollo.SuspenseQueryHookOptions<CommentQueryMyOperation, CommentQueryVariables>,
510+
): Apollo.UseSuspenseQueryResult<CommentQueryMyOperation | undefined, CommentQueryVariables>;
503511
export function useCommentSuspenseQuery(
504512
baseOptions?:
505513
| Apollo.SkipToken
506514
| Apollo.SuspenseQueryHookOptions<CommentQueryMyOperation, CommentQueryVariables>,
507515
) {
508-
const options =
509-
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
516+
if (baseOptions === Apollo.skipToken) {
517+
return Apollo.useSuspenseQuery<CommentQueryMyOperation, CommentQueryVariables>(
518+
CommentDocument,
519+
baseOptions as Apollo.SkipToken | undefined,
520+
);
521+
}
522+
const options = { ...defaultOptions, ...baseOptions };
510523
return Apollo.useSuspenseQuery<CommentQueryMyOperation, CommentQueryVariables>(
511524
CommentDocument,
512525
options,
@@ -564,6 +577,26 @@ export function useCurrentUserForProfileLazyQuery(
564577
CurrentUserForProfileQueryVariables
565578
>(CurrentUserForProfileDocument, options);
566579
}
580+
export function useCurrentUserForProfileSuspenseQuery(
581+
baseOptions?: Apollo.SuspenseQueryHookOptions<
582+
CurrentUserForProfileQueryMyOperation,
583+
CurrentUserForProfileQueryVariables
584+
>,
585+
): Apollo.UseSuspenseQueryResult<
586+
CurrentUserForProfileQueryMyOperation,
587+
CurrentUserForProfileQueryVariables
588+
>;
589+
export function useCurrentUserForProfileSuspenseQuery(
590+
baseOptions?:
591+
| Apollo.SkipToken
592+
| Apollo.SuspenseQueryHookOptions<
593+
CurrentUserForProfileQueryMyOperation,
594+
CurrentUserForProfileQueryVariables
595+
>,
596+
): Apollo.UseSuspenseQueryResult<
597+
CurrentUserForProfileQueryMyOperation | undefined,
598+
CurrentUserForProfileQueryVariables
599+
>;
567600
export function useCurrentUserForProfileSuspenseQuery(
568601
baseOptions?:
569602
| Apollo.SkipToken
@@ -572,8 +605,13 @@ export function useCurrentUserForProfileSuspenseQuery(
572605
CurrentUserForProfileQueryVariables
573606
>,
574607
) {
575-
const options =
576-
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
608+
if (baseOptions === Apollo.skipToken) {
609+
return Apollo.useSuspenseQuery<
610+
CurrentUserForProfileQueryMyOperation,
611+
CurrentUserForProfileQueryVariables
612+
>(CurrentUserForProfileDocument, baseOptions as Apollo.SkipToken | undefined);
613+
}
614+
const options = { ...defaultOptions, ...baseOptions };
577615
return Apollo.useSuspenseQuery<
578616
CurrentUserForProfileQueryMyOperation,
579617
CurrentUserForProfileQueryVariables
@@ -633,13 +671,26 @@ export function useFeedLazyQuery(
633671
const options = { ...defaultOptions, ...baseOptions };
634672
return Apollo.useLazyQuery<FeedQueryMyOperation, FeedQueryVariables>(FeedDocument, options);
635673
}
674+
export function useFeedSuspenseQuery(
675+
baseOptions?: Apollo.SuspenseQueryHookOptions<FeedQueryMyOperation, FeedQueryVariables>,
676+
): Apollo.UseSuspenseQueryResult<FeedQueryMyOperation, FeedQueryVariables>;
677+
export function useFeedSuspenseQuery(
678+
baseOptions?:
679+
| Apollo.SkipToken
680+
| Apollo.SuspenseQueryHookOptions<FeedQueryMyOperation, FeedQueryVariables>,
681+
): Apollo.UseSuspenseQueryResult<FeedQueryMyOperation | undefined, FeedQueryVariables>;
636682
export function useFeedSuspenseQuery(
637683
baseOptions?:
638684
| Apollo.SkipToken
639685
| Apollo.SuspenseQueryHookOptions<FeedQueryMyOperation, FeedQueryVariables>,
640686
) {
641-
const options =
642-
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
687+
if (baseOptions === Apollo.skipToken) {
688+
return Apollo.useSuspenseQuery<FeedQueryMyOperation, FeedQueryVariables>(
689+
FeedDocument,
690+
baseOptions as Apollo.SkipToken | undefined,
691+
);
692+
}
693+
const options = { ...defaultOptions, ...baseOptions };
643694
return Apollo.useSuspenseQuery<FeedQueryMyOperation, FeedQueryVariables>(FeedDocument, options);
644695
}
645696
export type FeedQueryHookResult = ReturnType<typeof useFeedQuery>;

dev-test/githunt/types.reactApollo.hooks.tsx

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -543,13 +543,26 @@ export function useCommentLazyQuery(
543543
const options = { ...defaultOptions, ...baseOptions };
544544
return Apollo.useLazyQuery<CommentQuery, CommentQueryVariables>(CommentDocument, options);
545545
}
546+
export function useCommentSuspenseQuery(
547+
baseOptions?: Apollo.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
548+
): Apollo.UseSuspenseQueryResult<CommentQuery, CommentQueryVariables>;
549+
export function useCommentSuspenseQuery(
550+
baseOptions?:
551+
| Apollo.SkipToken
552+
| Apollo.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
553+
): Apollo.UseSuspenseQueryResult<CommentQuery | undefined, CommentQueryVariables>;
546554
export function useCommentSuspenseQuery(
547555
baseOptions?:
548556
| Apollo.SkipToken
549557
| Apollo.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
550558
) {
551-
const options =
552-
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
559+
if (baseOptions === Apollo.skipToken) {
560+
return Apollo.useSuspenseQuery<CommentQuery, CommentQueryVariables>(
561+
CommentDocument,
562+
baseOptions as Apollo.SkipToken | undefined,
563+
);
564+
}
565+
const options = { ...defaultOptions, ...baseOptions };
553566
return Apollo.useSuspenseQuery<CommentQuery, CommentQueryVariables>(CommentDocument, options);
554567
}
555568
export type CommentQueryHookResult = ReturnType<typeof useCommentQuery>;
@@ -604,6 +617,23 @@ export function useCurrentUserForProfileLazyQuery(
604617
options,
605618
);
606619
}
620+
export function useCurrentUserForProfileSuspenseQuery(
621+
baseOptions?: Apollo.SuspenseQueryHookOptions<
622+
CurrentUserForProfileQuery,
623+
CurrentUserForProfileQueryVariables
624+
>,
625+
): Apollo.UseSuspenseQueryResult<CurrentUserForProfileQuery, CurrentUserForProfileQueryVariables>;
626+
export function useCurrentUserForProfileSuspenseQuery(
627+
baseOptions?:
628+
| Apollo.SkipToken
629+
| Apollo.SuspenseQueryHookOptions<
630+
CurrentUserForProfileQuery,
631+
CurrentUserForProfileQueryVariables
632+
>,
633+
): Apollo.UseSuspenseQueryResult<
634+
CurrentUserForProfileQuery | undefined,
635+
CurrentUserForProfileQueryVariables
636+
>;
607637
export function useCurrentUserForProfileSuspenseQuery(
608638
baseOptions?:
609639
| Apollo.SkipToken
@@ -612,8 +642,13 @@ export function useCurrentUserForProfileSuspenseQuery(
612642
CurrentUserForProfileQueryVariables
613643
>,
614644
) {
615-
const options =
616-
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
645+
if (baseOptions === Apollo.skipToken) {
646+
return Apollo.useSuspenseQuery<CurrentUserForProfileQuery, CurrentUserForProfileQueryVariables>(
647+
CurrentUserForProfileDocument,
648+
baseOptions as Apollo.SkipToken | undefined,
649+
);
650+
}
651+
const options = { ...defaultOptions, ...baseOptions };
617652
return Apollo.useSuspenseQuery<CurrentUserForProfileQuery, CurrentUserForProfileQueryVariables>(
618653
CurrentUserForProfileDocument,
619654
options,
@@ -673,11 +708,22 @@ export function useFeedLazyQuery(
673708
const options = { ...defaultOptions, ...baseOptions };
674709
return Apollo.useLazyQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
675710
}
711+
export function useFeedSuspenseQuery(
712+
baseOptions?: Apollo.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
713+
): Apollo.UseSuspenseQueryResult<FeedQuery, FeedQueryVariables>;
714+
export function useFeedSuspenseQuery(
715+
baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
716+
): Apollo.UseSuspenseQueryResult<FeedQuery | undefined, FeedQueryVariables>;
676717
export function useFeedSuspenseQuery(
677718
baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
678719
) {
679-
const options =
680-
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
720+
if (baseOptions === Apollo.skipToken) {
721+
return Apollo.useSuspenseQuery<FeedQuery, FeedQueryVariables>(
722+
FeedDocument,
723+
baseOptions as Apollo.SkipToken | undefined,
724+
);
725+
}
726+
const options = { ...defaultOptions, ...baseOptions };
681727
return Apollo.useSuspenseQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
682728
}
683729
export type FeedQueryHookResult = ReturnType<typeof useFeedQuery>;

dev-test/githunt/types.reactApollo.preResolveTypes.tsx

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -497,13 +497,26 @@ export function useCommentLazyQuery(
497497
const options = { ...defaultOptions, ...baseOptions };
498498
return Apollo.useLazyQuery<CommentQuery, CommentQueryVariables>(CommentDocument, options);
499499
}
500+
export function useCommentSuspenseQuery(
501+
baseOptions?: Apollo.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
502+
): Apollo.UseSuspenseQueryResult<CommentQuery, CommentQueryVariables>;
503+
export function useCommentSuspenseQuery(
504+
baseOptions?:
505+
| Apollo.SkipToken
506+
| Apollo.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
507+
): Apollo.UseSuspenseQueryResult<CommentQuery | undefined, CommentQueryVariables>;
500508
export function useCommentSuspenseQuery(
501509
baseOptions?:
502510
| Apollo.SkipToken
503511
| Apollo.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
504512
) {
505-
const options =
506-
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
513+
if (baseOptions === Apollo.skipToken) {
514+
return Apollo.useSuspenseQuery<CommentQuery, CommentQueryVariables>(
515+
CommentDocument,
516+
baseOptions as Apollo.SkipToken | undefined,
517+
);
518+
}
519+
const options = { ...defaultOptions, ...baseOptions };
507520
return Apollo.useSuspenseQuery<CommentQuery, CommentQueryVariables>(CommentDocument, options);
508521
}
509522
export type CommentQueryHookResult = ReturnType<typeof useCommentQuery>;
@@ -558,6 +571,23 @@ export function useCurrentUserForProfileLazyQuery(
558571
options,
559572
);
560573
}
574+
export function useCurrentUserForProfileSuspenseQuery(
575+
baseOptions?: Apollo.SuspenseQueryHookOptions<
576+
CurrentUserForProfileQuery,
577+
CurrentUserForProfileQueryVariables
578+
>,
579+
): Apollo.UseSuspenseQueryResult<CurrentUserForProfileQuery, CurrentUserForProfileQueryVariables>;
580+
export function useCurrentUserForProfileSuspenseQuery(
581+
baseOptions?:
582+
| Apollo.SkipToken
583+
| Apollo.SuspenseQueryHookOptions<
584+
CurrentUserForProfileQuery,
585+
CurrentUserForProfileQueryVariables
586+
>,
587+
): Apollo.UseSuspenseQueryResult<
588+
CurrentUserForProfileQuery | undefined,
589+
CurrentUserForProfileQueryVariables
590+
>;
561591
export function useCurrentUserForProfileSuspenseQuery(
562592
baseOptions?:
563593
| Apollo.SkipToken
@@ -566,8 +596,13 @@ export function useCurrentUserForProfileSuspenseQuery(
566596
CurrentUserForProfileQueryVariables
567597
>,
568598
) {
569-
const options =
570-
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
599+
if (baseOptions === Apollo.skipToken) {
600+
return Apollo.useSuspenseQuery<CurrentUserForProfileQuery, CurrentUserForProfileQueryVariables>(
601+
CurrentUserForProfileDocument,
602+
baseOptions as Apollo.SkipToken | undefined,
603+
);
604+
}
605+
const options = { ...defaultOptions, ...baseOptions };
571606
return Apollo.useSuspenseQuery<CurrentUserForProfileQuery, CurrentUserForProfileQueryVariables>(
572607
CurrentUserForProfileDocument,
573608
options,
@@ -627,11 +662,22 @@ export function useFeedLazyQuery(
627662
const options = { ...defaultOptions, ...baseOptions };
628663
return Apollo.useLazyQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
629664
}
665+
export function useFeedSuspenseQuery(
666+
baseOptions?: Apollo.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
667+
): Apollo.UseSuspenseQueryResult<FeedQuery, FeedQueryVariables>;
668+
export function useFeedSuspenseQuery(
669+
baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
670+
): Apollo.UseSuspenseQueryResult<FeedQuery | undefined, FeedQueryVariables>;
630671
export function useFeedSuspenseQuery(
631672
baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
632673
) {
633-
const options =
634-
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
674+
if (baseOptions === Apollo.skipToken) {
675+
return Apollo.useSuspenseQuery<FeedQuery, FeedQueryVariables>(
676+
FeedDocument,
677+
baseOptions as Apollo.SkipToken | undefined,
678+
);
679+
}
680+
const options = { ...defaultOptions, ...baseOptions };
635681
return Apollo.useSuspenseQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
636682
}
637683
export type FeedQueryHookResult = ReturnType<typeof useFeedQuery>;

dev-test/githunt/types.reactApollo.tsx

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -497,13 +497,26 @@ export function useCommentLazyQuery(
497497
const options = { ...defaultOptions, ...baseOptions };
498498
return Apollo.useLazyQuery<CommentQuery, CommentQueryVariables>(CommentDocument, options);
499499
}
500+
export function useCommentSuspenseQuery(
501+
baseOptions?: Apollo.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
502+
): Apollo.UseSuspenseQueryResult<CommentQuery, CommentQueryVariables>;
503+
export function useCommentSuspenseQuery(
504+
baseOptions?:
505+
| Apollo.SkipToken
506+
| Apollo.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
507+
): Apollo.UseSuspenseQueryResult<CommentQuery | undefined, CommentQueryVariables>;
500508
export function useCommentSuspenseQuery(
501509
baseOptions?:
502510
| Apollo.SkipToken
503511
| Apollo.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
504512
) {
505-
const options =
506-
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
513+
if (baseOptions === Apollo.skipToken) {
514+
return Apollo.useSuspenseQuery<CommentQuery, CommentQueryVariables>(
515+
CommentDocument,
516+
baseOptions as Apollo.SkipToken | undefined,
517+
);
518+
}
519+
const options = { ...defaultOptions, ...baseOptions };
507520
return Apollo.useSuspenseQuery<CommentQuery, CommentQueryVariables>(CommentDocument, options);
508521
}
509522
export type CommentQueryHookResult = ReturnType<typeof useCommentQuery>;
@@ -558,6 +571,23 @@ export function useCurrentUserForProfileLazyQuery(
558571
options,
559572
);
560573
}
574+
export function useCurrentUserForProfileSuspenseQuery(
575+
baseOptions?: Apollo.SuspenseQueryHookOptions<
576+
CurrentUserForProfileQuery,
577+
CurrentUserForProfileQueryVariables
578+
>,
579+
): Apollo.UseSuspenseQueryResult<CurrentUserForProfileQuery, CurrentUserForProfileQueryVariables>;
580+
export function useCurrentUserForProfileSuspenseQuery(
581+
baseOptions?:
582+
| Apollo.SkipToken
583+
| Apollo.SuspenseQueryHookOptions<
584+
CurrentUserForProfileQuery,
585+
CurrentUserForProfileQueryVariables
586+
>,
587+
): Apollo.UseSuspenseQueryResult<
588+
CurrentUserForProfileQuery | undefined,
589+
CurrentUserForProfileQueryVariables
590+
>;
561591
export function useCurrentUserForProfileSuspenseQuery(
562592
baseOptions?:
563593
| Apollo.SkipToken
@@ -566,8 +596,13 @@ export function useCurrentUserForProfileSuspenseQuery(
566596
CurrentUserForProfileQueryVariables
567597
>,
568598
) {
569-
const options =
570-
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
599+
if (baseOptions === Apollo.skipToken) {
600+
return Apollo.useSuspenseQuery<CurrentUserForProfileQuery, CurrentUserForProfileQueryVariables>(
601+
CurrentUserForProfileDocument,
602+
baseOptions as Apollo.SkipToken | undefined,
603+
);
604+
}
605+
const options = { ...defaultOptions, ...baseOptions };
571606
return Apollo.useSuspenseQuery<CurrentUserForProfileQuery, CurrentUserForProfileQueryVariables>(
572607
CurrentUserForProfileDocument,
573608
options,
@@ -627,11 +662,22 @@ export function useFeedLazyQuery(
627662
const options = { ...defaultOptions, ...baseOptions };
628663
return Apollo.useLazyQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
629664
}
665+
export function useFeedSuspenseQuery(
666+
baseOptions?: Apollo.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
667+
): Apollo.UseSuspenseQueryResult<FeedQuery, FeedQueryVariables>;
668+
export function useFeedSuspenseQuery(
669+
baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
670+
): Apollo.UseSuspenseQueryResult<FeedQuery | undefined, FeedQueryVariables>;
630671
export function useFeedSuspenseQuery(
631672
baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
632673
) {
633-
const options =
634-
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
674+
if (baseOptions === Apollo.skipToken) {
675+
return Apollo.useSuspenseQuery<FeedQuery, FeedQueryVariables>(
676+
FeedDocument,
677+
baseOptions as Apollo.SkipToken | undefined,
678+
);
679+
}
680+
const options = { ...defaultOptions, ...baseOptions };
635681
return Apollo.useSuspenseQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
636682
}
637683
export type FeedQueryHookResult = ReturnType<typeof useFeedQuery>;

0 commit comments

Comments
 (0)