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.

add internal helper for tada fragment unrolling (#285)

authored by

Jovi De Croock and committed by
GitHub
5e293e37 6a539468

+29 -1
+5
.changeset/tough-squids-worry.md
··· 1 + --- 2 + '@0no-co/graphqlsp': patch 3 + --- 4 + 5 + Add internal helper to unroll tada fragments
+1 -1
packages/graphqlsp/src/api.ts
··· 1 1 export { getGraphQLDiagnostics } from './diagnostics'; 2 2 export { init } from './ts'; 3 - export { findAllPersistedCallExpressions } from './ast'; 3 + export { findAllPersistedCallExpressions, unrollTadaFragments } from './ast'; 4 4 export { getDocumentReferenceFromTypeQuery } from './persisted';
+23
packages/graphqlsp/src/ast/index.ts
··· 101 101 return fragments; 102 102 } 103 103 104 + export function unrollTadaFragments( 105 + fragmentsArray: ts.ArrayLiteralExpression, 106 + wip: FragmentDefinitionNode[], 107 + info: ts.server.PluginCreateInfo 108 + ): FragmentDefinitionNode[] { 109 + fragmentsArray.elements.forEach(element => { 110 + if (ts.isIdentifier(element)) { 111 + wip.push(...unrollFragment(element, info)); 112 + } else if (ts.isPropertyAccessExpression(element)) { 113 + let el = element; 114 + while (ts.isPropertyAccessExpression(el.expression)) { 115 + el = el.expression; 116 + } 117 + 118 + if (ts.isIdentifier(el.name)) { 119 + wip.push(...unrollFragment(el.name, info)); 120 + } 121 + } 122 + }); 123 + 124 + return wip; 125 + } 126 + 104 127 export function findAllCallExpressions( 105 128 sourceFile: ts.SourceFile, 106 129 info: ts.server.PluginCreateInfo,