Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added useSuspenseQuery hook, remove top-level suspense: true #11746

Merged
merged 6 commits into from
Apr 6, 2022

Conversation

krishnaglick
Copy link
Contributor

@krishnaglick krishnaglick commented Apr 6, 2022

What

Removed the top-level Suspense configuration in favor of a useSuspenseQuery hook, swapping-in-place where appropriate.
No need for as QueryObserverSuccessResult<T>).data any more.

@krishnaglick krishnaglick requested a review from a team as a code owner April 6, 2022 00:53
@github-actions github-actions bot added area/frontend area/platform issues related to the platform labels Apr 6, 2022
@@ -27,6 +27,5 @@ export const useDocumentation = (documentationUrl: string): UseDocumentationResu
refetchOnMount: false,
refetchOnWindowFocus: false,
retry: false,
suspense: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suspense defaults to false now

@@ -42,7 +39,6 @@ export const useGetDestinationDefinitionSpecificationAsync = (

const escapedId = id ?? "";
return useQuery(destinationDefinitionSpecificationKeys.detail(escapedId), () => service.get(escapedId), {
suspense: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suspense defaults to false now

@@ -42,7 +39,6 @@ export const useGetSourceDefinitionSpecificationAsync = (

const escapedId = id ?? "";
return useQuery(sourceDefinitionSpecificationKeys.detail(escapedId), () => service.get(escapedId), {
suspense: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suspense defaults to false now

) {
return useQuery<TQueryFnData, TError, TData, TQueryKey>(queryKey, queryFn, {
...options,
suspense: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force suspense for the hook

return useQuery<TQueryFnData, TError, TData, TQueryKey>(queryKey, queryFn, {
...options,
suspense: true,
}).data as typeof options extends Disabled ? TData | undefined : TData;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We sometimes disable the call due to the rule of hooks. This lets typescript correctly infer the return type.

@@ -5,7 +5,6 @@ import { ReactQueryDevtools } from "react-query/devtools";
const queryClient = new QueryClient({
defaultOptions: {
queries: {
suspense: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defaults to false now since we have the new suspense hook.

Copy link
Contributor

@timroes timroes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested several parts of the UI (Cloud mode), nothing seemed to break. Code LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/platform issues related to the platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants