From 1d7e3dd5706c533d2224f6f1509a3367397c261b Mon Sep 17 00:00:00 2001 From: EYHN Date: Thu, 2 Nov 2023 15:20:08 +0800 Subject: [PATCH] fix(core): currentUser undefined when all workspaces deleted (#4812) --- packages/frontend/workspace/src/affine/gql.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/frontend/workspace/src/affine/gql.ts b/packages/frontend/workspace/src/affine/gql.ts index 6a6a30b738..102e5c7d31 100644 --- a/packages/frontend/workspace/src/affine/gql.ts +++ b/packages/frontend/workspace/src/affine/gql.ts @@ -8,6 +8,7 @@ import type { } from '@affine/graphql'; import { gqlFetcherFactory } from '@affine/graphql'; import type { GraphQLError } from 'graphql'; +import { useMemo } from 'react'; import type { Key, SWRConfiguration, SWRResponse } from 'swr'; import useSWR from 'swr'; import type { @@ -70,10 +71,18 @@ export function useQuery( options: QueryOptions, config?: any ) { + const configWithSuspense: SWRConfiguration = useMemo( + () => ({ + suspense: true, + ...config, + }), + [config] + ); + return useSWR( () => ['cloud', options.query.id, options.variables], () => fetcher(options), - config + configWithSuspense ); }