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

fix(lsp): nested call expressions (#319)

Changed files
+10 -5
.changeset
packages
example-tada
src
graphqlsp
+5
.changeset/tough-crabs-heal.md
···
+
---
+
'@0no-co/graphqlsp': patch
+
---
+
+
Support finding `graphql()` invocations within call-expressions
+2 -2
packages/example-tada/src/index.tsx
···
fleeRate
}
}
-
`, [PokemonFields, Fields.Pokemon]);
+
`, [PokemonFields, Fields.Pokemon])
-
const persisted = graphql.persisted<typeof PokemonQuery>("sha256:7a9bbe8533362e631f92af8d7f314b1589c8272f8e092da564d9ad6cd600a4eb")
+
const persisted = graphql.persisted<typeof PokemonQuery>("sha256:78c769ed6cfef67e17e579a2abfe4da27bd51e09ed832a88393148bcce4c5a7d")
const Pokemons = () => {
const [result] = useQuery({
+1 -1
packages/graphqlsp/src/ast/index.ts
···
// Check whether we've got a `graphql()` or `gql()` call, by the
// call expression's identifier
if (!checks.isGraphQLCall(node, typeChecker)) {
-
return;
+
return ts.forEachChild(node, find);
}
const name = checks.getSchemaName(node, typeChecker);
+1 -1
packages/graphqlsp/src/ast/resolve.ts
···
if (node.elements.every(ts.isIdentifier)) return node.elements;
const identifiers: ts.Identifier[] = [];
for (let element of node.elements) {
-
while (ts.isPropertyAccessExpression(element)) element = element.expression;
+
while (ts.isPropertyAccessExpression(element)) element = element.name;
if (ts.isIdentifier(element)) identifiers.push(element);
}
return identifiers;
+1 -1
packages/graphqlsp/src/index.ts
···
: positionOrRange.pos,
info
);
-
console.log('[GraphQLSP]', JSON.stringify(codefix));
+
if (codefix) {
return [
{