fix: handle gql error correctly (#7507)

This commit is contained in:
DarkSky 2024-07-15 17:24:43 +08:00 committed by GitHub
parent b50c57a3fa
commit 1f50c1b890
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 3 deletions

View File

@ -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';

View File

@ -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);
}

View File

@ -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';