Skip to content

Commit

Permalink
feat(typescript-react-apollo): support skip token for useSuspenseQuery (
Browse files Browse the repository at this point in the history
#835)

* feat(typescript-react-apollo): support skip token for useSuspenseQuery

* chore: generate changeset
  • Loading branch information
jefrydco authored Sep 9, 2024
1 parent 32d1b7d commit ea83cf4
Show file tree
Hide file tree
Showing 21 changed files with 262 additions and 155 deletions.
5 changes: 5 additions & 0 deletions .changeset/lazy-games-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-codegen/typescript-react-apollo': patch
---

feat: support skip token for useSuspenseQuery
27 changes: 18 additions & 9 deletions dev-test/githunt/types.reactApollo.customSuffix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,12 @@ export function useCommentLazyQuery(
);
}
export function useCommentSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<CommentQueryMyOperation, CommentQueryVariables>,
baseOptions?:
| Apollo.SkipToken
| Apollo.SuspenseQueryHookOptions<CommentQueryMyOperation, CommentQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
const options =
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<CommentQueryMyOperation, CommentQueryVariables>(
CommentDocument,
options,
Expand Down Expand Up @@ -562,12 +565,15 @@ export function useCurrentUserForProfileLazyQuery(
>(CurrentUserForProfileDocument, options);
}
export function useCurrentUserForProfileSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<
CurrentUserForProfileQueryMyOperation,
CurrentUserForProfileQueryVariables
>,
baseOptions?:
| Apollo.SkipToken
| Apollo.SuspenseQueryHookOptions<
CurrentUserForProfileQueryMyOperation,
CurrentUserForProfileQueryVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
const options =
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<
CurrentUserForProfileQueryMyOperation,
CurrentUserForProfileQueryVariables
Expand Down Expand Up @@ -628,9 +634,12 @@ export function useFeedLazyQuery(
return Apollo.useLazyQuery<FeedQueryMyOperation, FeedQueryVariables>(FeedDocument, options);
}
export function useFeedSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<FeedQueryMyOperation, FeedQueryVariables>,
baseOptions?:
| Apollo.SkipToken
| Apollo.SuspenseQueryHookOptions<FeedQueryMyOperation, FeedQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
const options =
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<FeedQueryMyOperation, FeedQueryVariables>(FeedDocument, options);
}
export type FeedQueryHookResult = ReturnType<typeof useFeedQuery>;
Expand Down
25 changes: 16 additions & 9 deletions dev-test/githunt/types.reactApollo.hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,12 @@ export function useCommentLazyQuery(
return Apollo.useLazyQuery<CommentQuery, CommentQueryVariables>(CommentDocument, options);
}
export function useCommentSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
baseOptions?:
| Apollo.SkipToken
| Apollo.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
const options =
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<CommentQuery, CommentQueryVariables>(CommentDocument, options);
}
export type CommentQueryHookResult = ReturnType<typeof useCommentQuery>;
Expand Down Expand Up @@ -602,12 +605,15 @@ export function useCurrentUserForProfileLazyQuery(
);
}
export function useCurrentUserForProfileSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<
CurrentUserForProfileQuery,
CurrentUserForProfileQueryVariables
>,
baseOptions?:
| Apollo.SkipToken
| Apollo.SuspenseQueryHookOptions<
CurrentUserForProfileQuery,
CurrentUserForProfileQueryVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
const options =
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<CurrentUserForProfileQuery, CurrentUserForProfileQueryVariables>(
CurrentUserForProfileDocument,
options,
Expand Down Expand Up @@ -668,9 +674,10 @@ export function useFeedLazyQuery(
return Apollo.useLazyQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
}
export function useFeedSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
const options =
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
}
export type FeedQueryHookResult = ReturnType<typeof useFeedQuery>;
Expand Down
25 changes: 16 additions & 9 deletions dev-test/githunt/types.reactApollo.preResolveTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,12 @@ export function useCommentLazyQuery(
return Apollo.useLazyQuery<CommentQuery, CommentQueryVariables>(CommentDocument, options);
}
export function useCommentSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
baseOptions?:
| Apollo.SkipToken
| Apollo.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
const options =
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<CommentQuery, CommentQueryVariables>(CommentDocument, options);
}
export type CommentQueryHookResult = ReturnType<typeof useCommentQuery>;
Expand Down Expand Up @@ -556,12 +559,15 @@ export function useCurrentUserForProfileLazyQuery(
);
}
export function useCurrentUserForProfileSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<
CurrentUserForProfileQuery,
CurrentUserForProfileQueryVariables
>,
baseOptions?:
| Apollo.SkipToken
| Apollo.SuspenseQueryHookOptions<
CurrentUserForProfileQuery,
CurrentUserForProfileQueryVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
const options =
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<CurrentUserForProfileQuery, CurrentUserForProfileQueryVariables>(
CurrentUserForProfileDocument,
options,
Expand Down Expand Up @@ -622,9 +628,10 @@ export function useFeedLazyQuery(
return Apollo.useLazyQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
}
export function useFeedSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
const options =
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
}
export type FeedQueryHookResult = ReturnType<typeof useFeedQuery>;
Expand Down
25 changes: 16 additions & 9 deletions dev-test/githunt/types.reactApollo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,12 @@ export function useCommentLazyQuery(
return Apollo.useLazyQuery<CommentQuery, CommentQueryVariables>(CommentDocument, options);
}
export function useCommentSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
baseOptions?:
| Apollo.SkipToken
| Apollo.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
const options =
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<CommentQuery, CommentQueryVariables>(CommentDocument, options);
}
export type CommentQueryHookResult = ReturnType<typeof useCommentQuery>;
Expand Down Expand Up @@ -556,12 +559,15 @@ export function useCurrentUserForProfileLazyQuery(
);
}
export function useCurrentUserForProfileSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<
CurrentUserForProfileQuery,
CurrentUserForProfileQueryVariables
>,
baseOptions?:
| Apollo.SkipToken
| Apollo.SuspenseQueryHookOptions<
CurrentUserForProfileQuery,
CurrentUserForProfileQueryVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
const options =
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<CurrentUserForProfileQuery, CurrentUserForProfileQueryVariables>(
CurrentUserForProfileDocument,
options,
Expand Down Expand Up @@ -622,9 +628,10 @@ export function useFeedLazyQuery(
return Apollo.useLazyQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
}
export function useFeedSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
const options =
baseOptions === Apollo.skipToken ? baseOptions : { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
}
export type FeedQueryHookResult = ReturnType<typeof useFeedQuery>;
Expand Down
33 changes: 24 additions & 9 deletions dev-test/githunt/types.reactApollo.v2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,14 @@ export function useCommentLazyQuery(
);
}
export function useCommentSuspenseQuery(
baseOptions?: ApolloReactHooks.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
baseOptions?:
| ApolloReactHooks.SkipToken
| ApolloReactHooks.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
const options =
baseOptions === ApolloReactHooks.skipToken
? baseOptions
: { ...defaultOptions, ...baseOptions };
return ApolloReactHooks.useSuspenseQuery<CommentQuery, CommentQueryVariables>(
CommentDocument,
options,
Expand Down Expand Up @@ -563,12 +568,17 @@ export function useCurrentUserForProfileLazyQuery(
>(CurrentUserForProfileDocument, options);
}
export function useCurrentUserForProfileSuspenseQuery(
baseOptions?: ApolloReactHooks.SuspenseQueryHookOptions<
CurrentUserForProfileQuery,
CurrentUserForProfileQueryVariables
>,
baseOptions?:
| ApolloReactHooks.SkipToken
| ApolloReactHooks.SuspenseQueryHookOptions<
CurrentUserForProfileQuery,
CurrentUserForProfileQueryVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
const options =
baseOptions === ApolloReactHooks.skipToken
? baseOptions
: { ...defaultOptions, ...baseOptions };
return ApolloReactHooks.useSuspenseQuery<
CurrentUserForProfileQuery,
CurrentUserForProfileQueryVariables
Expand Down Expand Up @@ -629,9 +639,14 @@ export function useFeedLazyQuery(
return ApolloReactHooks.useLazyQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
}
export function useFeedSuspenseQuery(
baseOptions?: ApolloReactHooks.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
baseOptions?:
| ApolloReactHooks.SkipToken
| ApolloReactHooks.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
const options =
baseOptions === ApolloReactHooks.skipToken
? baseOptions
: { ...defaultOptions, ...baseOptions };
return ApolloReactHooks.useSuspenseQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
}
export type FeedQueryHookResult = ReturnType<typeof useFeedQuery>;
Expand Down
10 changes: 5 additions & 5 deletions dev-test/star-wars/__generated__/HeroAndFriendsNames.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions dev-test/star-wars/__generated__/HeroAppearsIn.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions dev-test/star-wars/__generated__/HeroDetails.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions dev-test/star-wars/__generated__/HeroDetailsWithFragment.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions dev-test/star-wars/__generated__/HeroName.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 16 additions & 10 deletions dev-test/star-wars/__generated__/HeroNameConditional.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ea83cf4

Please sign in to comment.