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

Configure Feed

Select the types of activity you want to include in your feed.

create discernible error codes for diagnostics

+17 -3
+5
.changeset/two-dryers-rule.md
··· 1 + --- 2 + '@0no-co/graphqlsp': patch 3 + --- 4 + 5 + Improve the error-codes so they become discernible
+12 -3
packages/graphqlsp/src/diagnostics.ts
··· 26 26 import { resolveTemplate } from './ast/resolve'; 27 27 import { generateTypedDocumentNodes } from './graphql/generateTypes'; 28 28 29 - export const SEMANTIC_DIAGNOSTIC_CODE = 51001; 29 + export const SEMANTIC_DIAGNOSTIC_CODE = 52001; 30 + export const MISSING_OPERATION_NAME_CODE = 52002; 31 + export const MISSING_FRAGMENT_CODE = 52003; 32 + export const USING_DEPRECATED_FIELD_CODE = 52003; 30 33 31 34 export function getGraphQLDiagnostics( 32 35 filename: string, ··· 105 108 graphQLDiagnostics.push({ 106 109 message: 'Operation needs a name for types to be generated.', 107 110 start: node.pos, 111 + code: MISSING_OPERATION_NAME_CODE, 108 112 length: originalNode.getText().length, 109 113 range: {} as any, 110 114 severity: 2, ··· 126 130 diag.severity === 2 127 131 ? ts.DiagnosticCategory.Warning 128 132 : ts.DiagnosticCategory.Error, 129 - code: SEMANTIC_DIAGNOSTIC_CODE, 133 + code: 134 + typeof diag.code === 'number' 135 + ? diag.code 136 + : diag.severity === 2 137 + ? USING_DEPRECATED_FIELD_CODE 138 + : SEMANTIC_DIAGNOSTIC_CODE, 130 139 messageText: diag.message.split('\n')[0], 131 140 })); 132 141 ··· 214 223 length: imp.getText().length, 215 224 start: imp.getStart(), 216 225 category: ts.DiagnosticCategory.Message, 217 - code: SEMANTIC_DIAGNOSTIC_CODE, 226 + code: MISSING_FRAGMENT_CODE, 218 227 messageText: `Missing Fragment import(s) ${missingImports.join( 219 228 ', ' 220 229 )} from ${imp.moduleSpecifier.getText()}.`,