Skip to content
This repository was archived by the owner on Jul 31, 2022. It is now read-only.

Commit 6017872

Browse files
AumyFacao
authored andcommitted
feat: provide 'Execute Query' for /* GraphQL */ templates
1 parent f390366 commit 6017872

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

.changeset/silver-radios-invent.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"vscode-graphql": patch
3+
---
4+
5+
provide 'Execute Query' for `/* GraphQL */` templates

src/client/graphql-codelens-provider.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
CodeLens,
77
Range,
88
Position,
9+
ProviderResult,
910
} from "vscode"
1011

1112
import { SourceHelper, ExtractedTemplateLiteral } from "./source-helper"
@@ -23,10 +24,14 @@ export class GraphQLCodeLensProvider implements CodeLensProvider {
2324
public provideCodeLenses(
2425
document: TextDocument,
2526
_token: CancellationToken,
26-
): CodeLens[] {
27-
const literals: ExtractedTemplateLiteral[] =
28-
this.sourceHelper.extractAllTemplateLiterals(document, ["gql", "graphql"])
29-
return literals.map(literal => {
27+
// for some reason, ProviderResult<CodeLens[]> doesn't work here
28+
// anymore after upgrading types
29+
): ProviderResult<[]> {
30+
const literals: ExtractedTemplateLiteral[] = this.sourceHelper.extractAllTemplateLiterals(
31+
document,
32+
["gql", "graphql", "/\\* GraphQL \\*/"],
33+
)
34+
const results = literals.map(literal => {
3035
return new CodeLens(
3136
new Range(
3237
new Position(literal.position.line, 0),
@@ -39,5 +44,7 @@ export class GraphQLCodeLensProvider implements CodeLensProvider {
3944
},
4045
)
4146
})
47+
48+
return results as ProviderResult<[]>
4249
}
4350
}

0 commit comments

Comments
 (0)