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)

authored by

Jovi De Croock and committed by
GitHub
bc0f9cf6 45fe6613

+6 -3
+5
.changeset/six-chefs-hammer.md
··· 1 + --- 2 + '@0no-co/graphqlsp': patch 3 + --- 4 + 5 + Fix directives being misreported due to globally declared regex maintaining state
+1 -3
packages/graphqlsp/src/diagnostics.ts
··· 48 48 'inline', 49 49 ]); 50 50 51 - const directiveRegex = /Unknown directive "@([^)]+)"/g; 52 - 53 51 export const SEMANTIC_DIAGNOSTIC_CODE = 52001; 54 52 export const MISSING_OPERATION_NAME_CODE = 52002; 55 53 export const USING_DEPRECATED_FIELD_CODE = 52004; ··· 385 383 if (!diag.message.includes('Unknown directive')) return true; 386 384 387 385 const [message] = diag.message.split('('); 388 - const matches = directiveRegex.exec(message); 386 + const matches = /Unknown directive "@([^)]+)"/g.exec(message); 389 387 if (!matches) return true; 390 388 const directiveNmae = matches[1]; 391 389 return !clientDirectives.has(directiveNmae);