Skip to content

Commit

Permalink
Disable document symbol request for files over 1MB (#3430)
Browse files Browse the repository at this point in the history
* feat: disable document symbol request for files over 1MB
* Update packages/vscode-graphql/package.json
  • Loading branch information
yepitschunked authored Dec 11, 2023
1 parent 7daa163 commit fc1ea4c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/graphql-language-service-server/src/MessageProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions packages/vscode-graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 (one million).",
"default": 1000000
},
"vscode-graphql.rejectUnauthorized": {
"type": [
"boolean"
Expand Down

0 comments on commit fc1ea4c

Please sign in to comment.