Mirror: TypeScript LSP plugin that finds GraphQL documents in your code and provides diagnostics, auto-complete and hover-information.

prevent dupes (#100)

Changed files
+11 -1
.changeset
packages
graphqlsp
+5
.changeset/popular-bikes-clap.md
···
+
---
+
'@0no-co/graphqlsp': patch
+
---
+
+
Prevent duplicate async file-generation processes from happening
+6 -1
packages/graphqlsp/src/diagnostics.ts
···
export const MISSING_FRAGMENT_CODE = 52003;
export const USING_DEPRECATED_FIELD_CODE = 52004;
+
let isGeneratingTypes = false;
+
export function getGraphQLDiagnostics(
// This is so that we don't change offsets when there are
// TypeScript errors
···
!disableTypegen
) {
try {
-
if (isFileDirty(filename, source)) {
+
if (isFileDirty(filename, source) && !isGeneratingTypes) {
return tsDiagnostics;
}
+
isGeneratingTypes = true;
const parts = source.fileName.split('/');
const name = parts[parts.length - 1];
···
info.languageServiceHost.writeFile!(source.fileName, finalSourceText);
scriptInfo!.reloadFromFile();
scriptInfo!.registerFileUpdate();
+
isGeneratingTypes = false;
});
} catch (e) {
const scriptInfo = info.project.projectService.getScriptInfo(filename);
scriptInfo!.reloadFromFile();
+
isGeneratingTypes = false;
}
}