Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix: handle gql error correctly (#7507)

DarkSky1f50c1b8902f
diff --git a/packages/frontend/core/src/providers/swr-config-provider.tsx b/packages/frontend/core/src/providers/swr-config-provider.tsx
index 3bdae875f8..4abffaf6ac 100644
--- a/packages/frontend/core/src/providers/swr-config-provider.tsx
+++ b/packages/frontend/core/src/providers/swr-config-provider.tsx
@@ -1,6 +1,6 @@
import { notify } from '@affine/component';
+import { GraphQLError } from '@affine/graphql';
import { assertExists } from '@blocksuite/global/utils';
-import { GraphQLError } from 'graphql';
import type { PropsWithChildren, ReactNode } from 'react';
import { useCallback } from 'react';
import type { SWRConfiguration } from 'swr';
diff --git a/packages/frontend/graphql/src/error.ts b/packages/frontend/graphql/src/error.ts
index aee5571e67..6358d43939 100644
--- a/packages/frontend/graphql/src/error.ts
+++ b/packages/frontend/graphql/src/error.ts
@@ -26,7 +26,12 @@ export class UserFriendlyError implements UserFriendlyErrorResponse {
return new UserFriendlyError(response.extensions);
}
- if (typeof response === 'object' && response.type && response.name) {
+ if (
+ response &&
+ typeof response === 'object' &&
+ response.type &&
+ response.name
+ ) {
return new UserFriendlyError(response);
}
diff --git a/packages/frontend/graphql/src/fetcher.ts b/packages/frontend/graphql/src/fetcher.ts
index 0e721a98bd..b44e46dd04 100644
--- a/packages/frontend/graphql/src/fetcher.ts
+++ b/packages/frontend/graphql/src/fetcher.ts
@@ -1,7 +1,7 @@
import type { ExecutionResult } from 'graphql';
-import { GraphQLError } from 'graphql';
import { isNil, isObject, merge } from 'lodash-es';
+import { GraphQLError } from './error';
import type { GraphQLQuery } from './graphql';
import type { Mutations, Queries } from './schema';