From ccf4331ba92d9e1ab3fc789c509ddd99462d5620 Mon Sep 17 00:00:00 2001 From: James Styman <35004248+Namyts@users.noreply.github.com> Date: Fri, 12 Dec 2025 12:39:47 +0000 Subject: [PATCH] Fix regex patterns for gql parsing Allow for whitespace between query and opening curly bracket. It previously interpreted the curly as the operation name --- src/plugins/graphql/gqlHttpRegionParser.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/graphql/gqlHttpRegionParser.ts b/src/plugins/graphql/gqlHttpRegionParser.ts index d7b2d014..d84ba214 100644 --- a/src/plugins/graphql/gqlHttpRegionParser.ts +++ b/src/plugins/graphql/gqlHttpRegionParser.ts @@ -66,7 +66,7 @@ async function getGQLContent(lineReader: models.HttpLineGenerator): Promise[^\s(]+))?\s+<\s+(?.+)\s*$/u.exec(next.value.textLine); + const fileMatches = /^\s*gql(\s+(?[^\s({]+))?\s+<\s+(?.+)\s*$/u.exec(next.value.textLine); if (fileMatches && fileMatches.groups?.fileName) { const parserPath = fileMatches.groups.fileName.trim(); return { @@ -95,11 +95,11 @@ async function getGQLContent(lineReader: models.HttpLineGenerator): Promise fileProvider.readFile(path, 'utf-8')), }; } - const queryMatch = /^\s*(query|mutation)(\s+(?[^\s(]+))?/u.exec(next.value.textLine); + const queryMatch = /^\s*(query|mutation)(\s+(?[^\s({]+))?/u.exec(next.value.textLine); if (queryMatch) { return matchGqlContent(next.value, lineReader, queryMatch.groups?.name); } - const fragmentMatch = /^\s*(fragment)\s+(?[^\s(]+)\s+on\s+/u.exec(next.value.textLine); + const fragmentMatch = /^\s*(fragment)\s+(?[^\s({]+)\s+on\s+/u.exec(next.value.textLine); if (fragmentMatch) { return matchGqlContent(next.value, lineReader, fragmentMatch.groups?.name); }