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.

optimise parse performance

+20 -8
+5
.changeset/fresh-keys-promise.md
··· 1 + --- 2 + '@0no-co/graphqlsp': patch 3 + --- 4 + 5 + Optimise parse performance by omitting location information
+1
.prettierignore
··· 1 1 test/e2e/fixture-project/fixtures/**/* 2 + ./**/*.generated.ts
+1 -1
packages/graphqlsp/src/autoComplete.ts
··· 44 44 const text = resolveTemplate(node, filename, info); 45 45 let fragments: Array<FragmentDefinitionNode> = []; 46 46 try { 47 - const parsed = parse(text); 47 + const parsed = parse(text, { noLocation: true }); 48 48 fragments = parsed.definitions.filter( 49 49 x => x.kind === Kind.FRAGMENT_DEFINITION 50 50 ) as Array<FragmentDefinitionNode>;
+13 -7
packages/graphqlsp/src/diagnostics.ts
··· 96 96 }); 97 97 98 98 try { 99 - const parsed = parse(text); 99 + const parsed = parse(text, { noLocation: true }); 100 100 101 101 if ( 102 102 parsed.definitions.some(x => x.kind === Kind.OPERATION_DEFINITION) ··· 205 205 node.getSourceFile().fileName, 206 206 info 207 207 ); 208 - const parsed = parse(text); 209 - if ( 210 - parsed.definitions.every(x => x.kind === Kind.FRAGMENT_DEFINITION) 211 - ) { 212 - return `'${exp.name}'`; 208 + try { 209 + const parsed = parse(text, { noLocation: true }); 210 + if ( 211 + parsed.definitions.every( 212 + x => x.kind === Kind.FRAGMENT_DEFINITION 213 + ) 214 + ) { 215 + return `'${exp.name}'`; 216 + } 217 + } catch (e) { 218 + return; 213 219 } 214 220 } 215 221 }) ··· 263 269 264 270 nodes.forEach((node, i) => { 265 271 const queryText = texts[i] || ''; 266 - const parsed = parse(queryText); 272 + const parsed = parse(queryText, { noLocation: true }); 267 273 const isFragment = parsed.definitions.every( 268 274 x => x.kind === Kind.FRAGMENT_DEFINITION 269 275 );