From 283ef812c1a3a6de13d741aaf32cabbd6754a301 Mon Sep 17 00:00:00 2001 From: yepitschunked <125177+yepitschunked@users.noreply.github.com> Date: Tue, 3 Oct 2023 10:04:45 -0700 Subject: [PATCH 1/2] feat: disable document symbol request for files over 1MB --- .../src/MessageProcessor.ts | 16 ++++++++++++++++ packages/vscode-graphql/package.json | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/packages/graphql-language-service-server/src/MessageProcessor.ts b/packages/graphql-language-service-server/src/MessageProcessor.ts index 3d916c77954..49f332f29ea 100644 --- a/packages/graphql-language-service-server/src/MessageProcessor.ts +++ b/packages/graphql-language-service-server/src/MessageProcessor.ts @@ -837,6 +837,22 @@ export class MessageProcessor { return []; } + if ( + this._settings.largeFileThreshold !== undefined && + this._settings.largeFileThreshold < + cachedDocument.contents[0].query.length + ) { + return []; + } + + this._logger.log( + JSON.stringify({ + type: 'usage', + messageType: 'textDocument/documentSymbol', + fileName: textDocument.uri, + }), + ); + return this._languageService.getDocumentSymbols( cachedDocument.contents[0].query, textDocument.uri, diff --git a/packages/vscode-graphql/package.json b/packages/vscode-graphql/package.json index 6f7de13bcab..c9acf393483 100644 --- a/packages/vscode-graphql/package.json +++ b/packages/vscode-graphql/package.json @@ -93,6 +93,13 @@ ], "description": "Use a cached file output of your graphql-config schema result for definition lookups, symbols, outline, etc. Disabled by default." }, + "vscode-graphql.largeFileThreshold": { + "type": [ + "number" + ], + "description": "Disables outlining and other expensive operations for files larger than this threshold (in bytes). Defaults to 1000000.", + "default": 1000000 + }, "vscode-graphql.rejectUnauthorized": { "type": [ "boolean" From 367a247f9a7685c9a75afb7008e69cfc26850b74 Mon Sep 17 00:00:00 2001 From: yepitschunked <125177+yepitschunked@users.noreply.github.com> Date: Fri, 13 Oct 2023 16:44:24 -0700 Subject: [PATCH 2/2] Update packages/vscode-graphql/package.json Co-authored-by: Ted Thibodeau Jr --- packages/vscode-graphql/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vscode-graphql/package.json b/packages/vscode-graphql/package.json index c9acf393483..660763d9cfc 100644 --- a/packages/vscode-graphql/package.json +++ b/packages/vscode-graphql/package.json @@ -97,7 +97,7 @@ "type": [ "number" ], - "description": "Disables outlining and other expensive operations for files larger than this threshold (in bytes). Defaults to 1000000.", + "description": "Disables outlining and other expensive operations for files larger than this threshold (in bytes). Defaults to 1000000 (one million).", "default": 1000000 }, "vscode-graphql.rejectUnauthorized": {