From 7a2c6ff41d88302ffd4adb8eb17dede5231ea74e Mon Sep 17 00:00:00 2001 From: Sergii Grebeniuk Date: Mon, 30 Sep 2024 13:28:26 +0200 Subject: [PATCH] fix: Revert "fix: import `graphql` lazily (#2250)" This reverts commit 1799e0638f0f860c19ba46db7c4287012f2cb716. --- src/core/utils/internal/parseGraphQLRequest.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/core/utils/internal/parseGraphQLRequest.ts b/src/core/utils/internal/parseGraphQLRequest.ts index 81f6b1097..62fa55379 100644 --- a/src/core/utils/internal/parseGraphQLRequest.ts +++ b/src/core/utils/internal/parseGraphQLRequest.ts @@ -3,6 +3,7 @@ import type { OperationDefinitionNode, OperationTypeNode, } from 'graphql' +import { parse } from 'graphql' import type { GraphQLVariables } from '../../handlers/GraphQLHandler' import { toPublicUrl } from '../request/toPublicUrl' import { devUtils } from './devUtils' @@ -39,14 +40,7 @@ export function parseDocumentNode(node: DocumentNode): ParsedGraphQLQuery { } } -async function parseQuery(query: string): Promise { - const { parse } = await import('graphql').catch((error) => { - devUtils.error( - 'Failed to parse a GraphQL query: cannot import the "graphql" module. Please make sure you install it if you wish to intercept GraphQL requests. See the original import error below.', - ) - throw error - }) - +function parseQuery(query: string): ParsedGraphQLQuery | Error { try { const ast = parse(query) return parseDocumentNode(ast) @@ -187,7 +181,7 @@ export async function parseGraphQLRequest( } const { query, variables } = input - const parsedResult = await parseQuery(query) + const parsedResult = parseQuery(query) if (parsedResult instanceof Error) { const requestPublicUrl = toPublicUrl(request.url)