From f3840e43424bdd91322365ce84d5bb996f884765 Mon Sep 17 00:00:00 2001 From: Anwarul Islam Date: Wed, 5 Mar 2025 20:25:07 +0600 Subject: [PATCH] fix(common): make `cursorPosition` field optional in `HoppGQLDocument` type (#4834) --- packages/hoppscotch-common/src/helpers/graphql/document.ts | 2 +- packages/hoppscotch-common/src/helpers/graphql/query.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/hoppscotch-common/src/helpers/graphql/document.ts b/packages/hoppscotch-common/src/helpers/graphql/document.ts index f501e069..de49524a 100644 --- a/packages/hoppscotch-common/src/helpers/graphql/document.ts +++ b/packages/hoppscotch-common/src/helpers/graphql/document.ts @@ -56,7 +56,7 @@ export type HoppGQLDocument = { /** * The cursor position in the document */ - cursorPosition: number + cursorPosition?: number /** * Info about where this request should be saved. diff --git a/packages/hoppscotch-common/src/helpers/graphql/query.ts b/packages/hoppscotch-common/src/helpers/graphql/query.ts index 473f93cb..3d7084d3 100644 --- a/packages/hoppscotch-common/src/helpers/graphql/query.ts +++ b/packages/hoppscotch-common/src/helpers/graphql/query.ts @@ -310,7 +310,9 @@ export function useQuery() { if (!currentTab) return const currentQuery = currentTab.document.request.query || "" - const selectedOperation = getOperation(currentTab.document.cursorPosition) + const selectedOperation = getOperation( + currentTab.document.cursorPosition || 0 + ) const navItems = [...navStack.value, { name: item.name, def: item }] const result = processOperation( @@ -368,7 +370,7 @@ export function useQuery() { isArgument = false ): boolean => { const operation = getOperation( - tabs.currentActiveTab.value?.document.cursorPosition + tabs.currentActiveTab.value?.document.cursorPosition || 0 ) if (!operation) return false