diff --git a/.changeset/chilly-birds-poke.md b/.changeset/chilly-birds-poke.md new file mode 100644 index 00000000000..54376e0175f --- /dev/null +++ b/.changeset/chilly-birds-poke.md @@ -0,0 +1,6 @@ +--- +"graphql-language-service-server": patch +"graphql-language-service": patch +--- + +Do not log errors when a JS/TS file has no embedded graphql tags diff --git a/packages/graphql-language-service-server/src/MessageProcessor.ts b/packages/graphql-language-service-server/src/MessageProcessor.ts index 58c694faa2f..dd053110d86 100644 --- a/packages/graphql-language-service-server/src/MessageProcessor.ts +++ b/packages/graphql-language-service-server/src/MessageProcessor.ts @@ -485,7 +485,7 @@ export class MessageProcessor { const cachedDocument = this._getCachedDocument(textDocument.uri); if (!cachedDocument) { - throw new Error('A cached document cannot be found.'); + return []; } const found = cachedDocument.contents.find(content => { @@ -537,7 +537,7 @@ export class MessageProcessor { const cachedDocument = this._getCachedDocument(textDocument.uri); if (!cachedDocument) { - throw new Error('A cached document cannot be found.'); + return { contents: [] }; } const found = cachedDocument.contents.find(content => { @@ -749,8 +749,9 @@ export class MessageProcessor { const textDocument = params.textDocument; const cachedDocument = this._getCachedDocument(textDocument.uri); if (!cachedDocument || !cachedDocument.contents[0]) { - throw new Error('A cached document cannot be found.'); + return []; } + return this._languageService.getDocumentSymbols( cachedDocument.contents[0].query, textDocument.uri,