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.

fix(graphqlsp): Fix resolving fragments as assignments (#322)

authored by

Phil Pluckthun and committed by
GitHub
1d5d9a65 b6fab060

+15
+5
.changeset/fuzzy-donkeys-kneel.md
··· 1 + --- 2 + '@0no-co/graphqlsp': patch 3 + --- 4 + 5 + Fix fragments not being resolved when they're assigned to a property on an arbitrary identifier as an identifier.
+10
packages/graphqlsp/src/ast/index.ts
··· 70 70 let found = findNode(externalSource, fragment.textSpan.start); 71 71 if (!found) return fragments; 72 72 73 + while (ts.isPropertyAccessExpression(found.parent)) found = found.parent; 74 + 73 75 if ( 74 76 ts.isVariableDeclaration(found.parent) && 75 77 found.parent.initializer && ··· 78 80 found = found.parent.initializer; 79 81 } else if (ts.isPropertyAssignment(found.parent)) { 80 82 found = found.parent.initializer; 83 + } else if (ts.isBinaryExpression(found.parent)) { 84 + found = found.parent.right; 85 + } 86 + 87 + // If we found another identifier, we repeat trying to find the original 88 + // fragment definition 89 + if (ts.isIdentifier(found)) { 90 + return unrollFragment(found, info, typeChecker); 81 91 } 82 92 83 93 // Check whether we've got a `graphql()` or `gql()` call, by the