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(lsp): nested call expressions (#319)

authored by

Jovi De Croock and committed by
GitHub
b153ce16 b8997a55

+10 -5
+5
.changeset/tough-crabs-heal.md
··· 1 + --- 2 + '@0no-co/graphqlsp': patch 3 + --- 4 + 5 + Support finding `graphql()` invocations within call-expressions
+2 -2
packages/example-tada/src/index.tsx
··· 30 30 fleeRate 31 31 } 32 32 } 33 - `, [PokemonFields, Fields.Pokemon]); 33 + `, [PokemonFields, Fields.Pokemon]) 34 34 35 - const persisted = graphql.persisted<typeof PokemonQuery>("sha256:7a9bbe8533362e631f92af8d7f314b1589c8272f8e092da564d9ad6cd600a4eb") 35 + const persisted = graphql.persisted<typeof PokemonQuery>("sha256:78c769ed6cfef67e17e579a2abfe4da27bd51e09ed832a88393148bcce4c5a7d") 36 36 37 37 const Pokemons = () => { 38 38 const [result] = useQuery({
+1 -1
packages/graphqlsp/src/ast/index.ts
··· 153 153 // Check whether we've got a `graphql()` or `gql()` call, by the 154 154 // call expression's identifier 155 155 if (!checks.isGraphQLCall(node, typeChecker)) { 156 - return; 156 + return ts.forEachChild(node, find); 157 157 } 158 158 159 159 const name = checks.getSchemaName(node, typeChecker);
+1 -1
packages/graphqlsp/src/ast/resolve.ts
··· 158 158 if (node.elements.every(ts.isIdentifier)) return node.elements; 159 159 const identifiers: ts.Identifier[] = []; 160 160 for (let element of node.elements) { 161 - while (ts.isPropertyAccessExpression(element)) element = element.expression; 161 + while (ts.isPropertyAccessExpression(element)) element = element.name; 162 162 if (ts.isIdentifier(element)) identifiers.push(element); 163 163 } 164 164 return identifiers;
+1 -1
packages/graphqlsp/src/index.ts
··· 162 162 : positionOrRange.pos, 163 163 info 164 164 ); 165 - console.log('[GraphQLSP]', JSON.stringify(codefix)); 165 + 166 166 if (codefix) { 167 167 return [ 168 168 {