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

fix(diag): directive miss report with multiple documents (#293)

Changed files
+6 -3
.changeset
packages
graphqlsp
+5
.changeset/six-chefs-hammer.md
···
+
---
+
'@0no-co/graphqlsp': patch
+
---
+
+
Fix directives being misreported due to globally declared regex maintaining state
+1 -3
packages/graphqlsp/src/diagnostics.ts
···
'inline',
]);
-
const directiveRegex = /Unknown directive "@([^)]+)"/g;
-
export const SEMANTIC_DIAGNOSTIC_CODE = 52001;
export const MISSING_OPERATION_NAME_CODE = 52002;
export const USING_DEPRECATED_FIELD_CODE = 52004;
···
if (!diag.message.includes('Unknown directive')) return true;
const [message] = diag.message.split('(');
-
const matches = directiveRegex.exec(message);
+
const matches = /Unknown directive "@([^)]+)"/g.exec(message);
if (!matches) return true;
const directiveNmae = matches[1];
return !clientDirectives.has(directiveNmae);