vscode-apollo 1.19.3 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.changeset/README.md +8 -0
- package/.changeset/config.json +14 -0
- package/.circleci/config.yml +82 -0
- package/.eslintrc.js +10 -0
- package/.gitattributes +1 -0
- package/.github/workflows/release.yml +95 -0
- package/.gitleaks.toml +26 -0
- package/.nvmrc +1 -0
- package/.prettierrc +5 -0
- package/.vscode/launch.json +61 -0
- package/.vscode/settings.json +16 -0
- package/.vscode/tasks.json +18 -0
- package/.vscodeignore +17 -1
- package/CHANGELOG.md +172 -1
- package/LICENSE +2 -2
- package/README.md +9 -9
- package/codegen.yml +12 -0
- package/images/IconRun.svg +8 -0
- package/jest.config.ts +11 -0
- package/package.json +102 -22
- package/renovate.json +23 -0
- package/src/__mocks__/fs.js +3 -0
- package/src/__tests__/statusBar.test.ts +8 -7
- package/src/debug.ts +2 -5
- package/src/env/fetch/fetch.ts +32 -0
- package/src/env/fetch/global.ts +30 -0
- package/src/env/fetch/index.d.ts +2 -0
- package/src/env/fetch/index.ts +2 -0
- package/src/env/fetch/url.ts +9 -0
- package/src/env/index.ts +4 -0
- package/src/env/polyfills/array.ts +17 -0
- package/src/env/polyfills/index.ts +2 -0
- package/src/env/polyfills/object.ts +7 -0
- package/src/env/typescript-utility-types.ts +2 -0
- package/src/extension.ts +106 -37
- package/src/language-server/__tests__/diagnostics.test.ts +86 -0
- package/src/language-server/__tests__/document.test.ts +187 -0
- package/src/language-server/__tests__/fileSet.test.ts +46 -0
- package/src/language-server/__tests__/fixtures/starwarsSchema.ts +1917 -0
- package/src/language-server/config/__tests__/config.ts +128 -0
- package/src/language-server/config/__tests__/loadConfig.ts +508 -0
- package/src/language-server/config/__tests__/utils.ts +106 -0
- package/src/language-server/config/config.ts +219 -0
- package/src/language-server/config/index.ts +3 -0
- package/src/language-server/config/loadConfig.ts +228 -0
- package/src/language-server/config/utils.ts +56 -0
- package/src/language-server/diagnostics.ts +109 -0
- package/src/language-server/document.ts +277 -0
- package/src/language-server/engine/GraphQLDataSource.ts +124 -0
- package/src/language-server/engine/index.ts +105 -0
- package/src/language-server/engine/operations/frontendUrlRoot.ts +7 -0
- package/src/language-server/engine/operations/schemaTagsAndFieldStats.ts +24 -0
- package/src/language-server/errors/__tests__/NoMissingClientDirectives.test.ts +220 -0
- package/src/language-server/errors/logger.ts +58 -0
- package/src/language-server/errors/validation.ts +277 -0
- package/src/language-server/fileSet.ts +65 -0
- package/src/language-server/format.ts +48 -0
- package/src/language-server/graphqlTypes.ts +7176 -0
- package/src/language-server/index.ts +29 -0
- package/src/language-server/languageProvider.ts +798 -0
- package/src/language-server/loadingHandler.ts +64 -0
- package/src/language-server/project/base.ts +399 -0
- package/src/language-server/project/client.ts +602 -0
- package/src/language-server/project/defaultClientSchema.ts +45 -0
- package/src/language-server/project/service.ts +48 -0
- package/src/language-server/providers/schema/__tests__/file.ts +150 -0
- package/src/language-server/providers/schema/base.ts +15 -0
- package/src/language-server/providers/schema/endpoint.ts +157 -0
- package/src/language-server/providers/schema/engine.ts +197 -0
- package/src/language-server/providers/schema/file.ts +167 -0
- package/src/language-server/providers/schema/index.ts +75 -0
- package/src/language-server/server.ts +252 -0
- package/src/language-server/typings/codemirror.d.ts +4 -0
- package/src/language-server/typings/graphql.d.ts +27 -0
- package/src/language-server/utilities/__tests__/graphql.test.ts +411 -0
- package/src/language-server/utilities/__tests__/uri.ts +55 -0
- package/src/language-server/utilities/debouncer.ts +8 -0
- package/src/language-server/utilities/debug.ts +89 -0
- package/src/language-server/utilities/graphql.ts +432 -0
- package/src/language-server/utilities/index.ts +3 -0
- package/src/language-server/utilities/source.ts +182 -0
- package/src/language-server/utilities/uri.ts +19 -0
- package/src/language-server/workspace.ts +262 -0
- package/src/languageServerClient.ts +19 -12
- package/src/messages.ts +84 -0
- package/src/statusBar.ts +5 -5
- package/src/tools/__tests__/buildServiceDefinition.test.ts +491 -0
- package/src/tools/__tests__/snapshotSerializers/astSerializer.ts +19 -0
- package/src/tools/__tests__/snapshotSerializers/graphQLTypeSerializer.ts +14 -0
- package/src/tools/buildServiceDefinition.ts +241 -0
- package/src/tools/index.ts +6 -0
- package/src/tools/schema/index.ts +2 -0
- package/src/tools/schema/resolveObject.ts +18 -0
- package/src/tools/schema/resolverMap.ts +23 -0
- package/src/tools/utilities/graphql.ts +22 -0
- package/src/tools/utilities/index.ts +3 -0
- package/src/tools/utilities/invariant.ts +5 -0
- package/src/tools/utilities/predicates.ts +5 -0
- package/src/utils.ts +1 -16
- package/syntaxes/graphql.js.json +3 -3
- package/syntaxes/graphql.json +13 -9
- package/syntaxes/graphql.lua.json +51 -0
- package/syntaxes/graphql.rb.json +1 -1
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +20 -7
- package/create-server-symlink.js +0 -8
- package/lib/debug.d.ts +0 -11
- package/lib/debug.d.ts.map +0 -1
- package/lib/debug.js +0 -48
- package/lib/debug.js.map +0 -1
- package/lib/extension.d.ts +0 -4
- package/lib/extension.d.ts.map +0 -1
- package/lib/extension.js +0 -187
- package/lib/extension.js.map +0 -1
- package/lib/languageServerClient.d.ts +0 -4
- package/lib/languageServerClient.d.ts.map +0 -1
- package/lib/languageServerClient.js +0 -57
- package/lib/languageServerClient.js.map +0 -1
- package/lib/statusBar.d.ts +0 -24
- package/lib/statusBar.d.ts.map +0 -1
- package/lib/statusBar.js +0 -46
- package/lib/statusBar.js.map +0 -1
- package/lib/testRunner/index.d.ts +0 -3
- package/lib/testRunner/index.d.ts.map +0 -1
- package/lib/testRunner/index.js +0 -49
- package/lib/testRunner/index.js.map +0 -1
- package/lib/testRunner/jest-config.d.ts +0 -14
- package/lib/testRunner/jest-config.d.ts.map +0 -1
- package/lib/testRunner/jest-config.js +0 -18
- package/lib/testRunner/jest-config.js.map +0 -1
- package/lib/testRunner/jest-vscode-environment.d.ts +0 -2
- package/lib/testRunner/jest-vscode-environment.d.ts.map +0 -1
- package/lib/testRunner/jest-vscode-environment.js +0 -19
- package/lib/testRunner/jest-vscode-environment.js.map +0 -1
- package/lib/testRunner/jest-vscode-framework-setup.d.ts +0 -1
- package/lib/testRunner/jest-vscode-framework-setup.d.ts.map +0 -1
- package/lib/testRunner/jest-vscode-framework-setup.js +0 -3
- package/lib/testRunner/jest-vscode-framework-setup.js.map +0 -1
- package/lib/testRunner/vscode-test-script.d.ts +0 -2
- package/lib/testRunner/vscode-test-script.d.ts.map +0 -1
- package/lib/testRunner/vscode-test-script.js +0 -23
- package/lib/testRunner/vscode-test-script.js.map +0 -1
- package/lib/utils.d.ts +0 -18
- package/lib/utils.d.ts.map +0 -1
- package/lib/utils.js +0 -52
- package/lib/utils.js.map +0 -1
- package/src/testRunner/README.md +0 -23
- package/src/testRunner/index.ts +0 -72
- package/src/testRunner/jest-config.ts +0 -17
- package/src/testRunner/jest-vscode-environment.ts +0 -25
- package/src/testRunner/jest-vscode-framework-setup.ts +0 -10
- package/src/testRunner/jest.d.ts +0 -37
- package/src/testRunner/vscode-test-script.ts +0 -38
- package/tsconfig.test.json +0 -4
- package/tsconfig.tsbuildinfo +0 -2486
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" viewBox="0 0 20 20" width="7" height="7">
|
|
2
|
+
<title>
|
|
3
|
+
Exported from Streamline App (https://app.streamlineicons.com)
|
|
4
|
+
</title>
|
|
5
|
+
<g transform="matrix(2.54 0 0 2.54 10 9.97)" id="LVKu-U2gXNoh456TxJx47" >
|
|
6
|
+
<path style="stroke: rgb(255,255,255); stroke-width: 1; stroke-dasharray: none; stroke-linecap: round; stroke-dashoffset: 0; stroke-linejoin: round; stroke-miterlimit: 4; fill: #2075D6; fill-rule: evenodd; opacity: 1;" vector-effect="non-scaling-stroke" transform=" translate(-10.25, -9.71)" d="M 7 6.502 L 7 12.926 C 7 13.293 7.317 13.534 7.592 13.379 L 13.259 10.166 C 13.408058725855952 10.063593398311438 13.49712261259461 9.89434694032026 13.49712261259461 9.7135 C 13.49712261259461 9.532653059679742 13.408058725855952 9.363406601688563 13.259 9.261000000000001 L 7.592 6.047 C 7.317 5.893 7 6.135 7 6.502 Z" stroke-linecap="round" />
|
|
7
|
+
</g>
|
|
8
|
+
</svg>
|
package/jest.config.ts
ADDED
package/package.json
CHANGED
|
@@ -2,36 +2,93 @@
|
|
|
2
2
|
"name": "vscode-apollo",
|
|
3
3
|
"displayName": "Apollo GraphQL",
|
|
4
4
|
"description": "Rich editor support for GraphQL client and server development that seamlessly integrates with the Apollo platform",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.20.0",
|
|
6
6
|
"referenceID": "87197759-7617-40d0-b32e-46d378e907c7",
|
|
7
7
|
"author": "Apollo GraphQL <opensource@apollographql.com>",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/apollographql/
|
|
11
|
+
"url": "https://github.com/apollographql/vscode-graphql"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://github.com/apollographql/
|
|
14
|
-
"bugs": "https://github.com/apollographql/
|
|
13
|
+
"homepage": "https://github.com/apollographql/vscode-graphql",
|
|
14
|
+
"bugs": "https://github.com/apollographql/vscode-graphql/issues",
|
|
15
15
|
"main": "./lib/extension",
|
|
16
16
|
"types": "lib/index.d.ts",
|
|
17
17
|
"scripts": {
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"test": "
|
|
18
|
+
"build": "tsc --build tsconfig.build.json",
|
|
19
|
+
"build:clean": "npm run build -- --clean",
|
|
20
|
+
"watch": "npm run build -- --watch",
|
|
21
|
+
"postinstall": "npx vscode-install",
|
|
22
|
+
"changeset-version": "changeset version && npm ci --ignore-scripts",
|
|
23
|
+
"changeset-publish": "npm run build && changeset publish",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"lint": "eslint src --ext .ts",
|
|
26
|
+
"test-unit": "jest",
|
|
27
|
+
"codegen": "graphql-codegen"
|
|
27
28
|
},
|
|
28
29
|
"engines": {
|
|
29
30
|
"vscode": "^1.30.0"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
|
-
"apollo
|
|
33
|
-
"
|
|
34
|
-
"
|
|
33
|
+
"@apollo/federation": "^0.23.1",
|
|
34
|
+
"@endemolshinegroup/cosmiconfig-typescript-loader": "^1.0.0",
|
|
35
|
+
"@types/lz-string": "^1.3.34",
|
|
36
|
+
"@types/node-fetch": "2.5.10",
|
|
37
|
+
"apollo-datasource": "^0.8.0",
|
|
38
|
+
"apollo-link": "^1.2.3",
|
|
39
|
+
"apollo-link-context": "^1.0.9",
|
|
40
|
+
"apollo-link-error": "^1.1.1",
|
|
41
|
+
"apollo-link-http": "^1.5.5",
|
|
42
|
+
"apollo-server-errors": "^2.0.2",
|
|
43
|
+
"await-to-js": "^2.0.1",
|
|
44
|
+
"codemirror": "^5.63.3",
|
|
45
|
+
"core-js": "^3.0.1",
|
|
46
|
+
"cosmiconfig": "^5.0.6",
|
|
47
|
+
"dotenv": "^10.0.0",
|
|
48
|
+
"glob": "^7.1.3",
|
|
49
|
+
"graphql": "^15.5.0",
|
|
50
|
+
"graphql-language-service-interface": "^2.8.4",
|
|
51
|
+
"graphql-tag": "^2.10.1",
|
|
52
|
+
"lodash.debounce": "^4.0.8",
|
|
53
|
+
"lodash.merge": "^4.6.1",
|
|
54
|
+
"lz-string": "^1.4.4",
|
|
55
|
+
"minimatch": "^3.0.4",
|
|
56
|
+
"moment": "^2.29.1",
|
|
57
|
+
"node-fetch": "^2.2.0",
|
|
58
|
+
"query-string": "^7.0.1",
|
|
59
|
+
"resolve-from": "^5.0.0",
|
|
60
|
+
"sha.js": "^2.4.11",
|
|
61
|
+
"vscode-languageclient": "^5.2.1",
|
|
62
|
+
"vscode-languageserver": "^5.1.0",
|
|
63
|
+
"vscode-uri": "1.0.6"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@changesets/changelog-github": "^0.4.8",
|
|
67
|
+
"@changesets/cli": "^2.26.2",
|
|
68
|
+
"@graphql-codegen/cli": "^2.2.0",
|
|
69
|
+
"@graphql-codegen/typescript-operations": "^2.1.3",
|
|
70
|
+
"@types/cosmiconfig": "5.0.3",
|
|
71
|
+
"@types/glob": "7.1.1",
|
|
72
|
+
"@types/jest": "^26.0.24",
|
|
73
|
+
"@types/lodash.debounce": "4.0.6",
|
|
74
|
+
"@types/lodash.merge": "4.6.6",
|
|
75
|
+
"@types/node": "^14.14.41",
|
|
76
|
+
"@types/node-fetch": "2.5.10",
|
|
77
|
+
"@typescript-eslint/eslint-plugin": "^4.29.0",
|
|
78
|
+
"@typescript-eslint/parser": "^4.29.0",
|
|
79
|
+
"eslint": "^7.32.0",
|
|
80
|
+
"eslint-config-prettier": "^8.3.0",
|
|
81
|
+
"eslint-plugin-prettier": "^3.4.0",
|
|
82
|
+
"jest": "^27.0.6",
|
|
83
|
+
"jest-environment-node": "^26.6.2",
|
|
84
|
+
"jest-junit": "^12.2.0",
|
|
85
|
+
"memfs": "^3.2.2",
|
|
86
|
+
"prettier": "^2.3.2",
|
|
87
|
+
"rimraf": "^3.0.2",
|
|
88
|
+
"ts-jest": "^27.0.4",
|
|
89
|
+
"typescript": "^4.3.5",
|
|
90
|
+
"vsce": "^1.87.1",
|
|
91
|
+
"vscode": "^1.1.37"
|
|
35
92
|
},
|
|
36
93
|
"publisher": "apollographql",
|
|
37
94
|
"categories": [
|
|
@@ -40,12 +97,13 @@
|
|
|
40
97
|
],
|
|
41
98
|
"icon": "images/icon-apollo-blue-400x400.png",
|
|
42
99
|
"activationEvents": [
|
|
43
|
-
"workspaceContains:**/apollo.config.[jt]s"
|
|
100
|
+
"workspaceContains:**/apollo.config.[jt]s",
|
|
101
|
+
"workspaceContains:**/apollo.config.cjs"
|
|
44
102
|
],
|
|
45
103
|
"contributes": {
|
|
46
104
|
"configuration": {
|
|
47
105
|
"type": "object",
|
|
48
|
-
"title": "
|
|
106
|
+
"title": "Apollo GraphQL",
|
|
49
107
|
"properties": {
|
|
50
108
|
"apollographql.trace.server": {
|
|
51
109
|
"scope": "window",
|
|
@@ -57,6 +115,18 @@
|
|
|
57
115
|
],
|
|
58
116
|
"default": "off",
|
|
59
117
|
"description": "Traces the communication between VS Code and the language server."
|
|
118
|
+
},
|
|
119
|
+
"apollographql.debug.revealOutputOnLanguageServerError": {
|
|
120
|
+
"type": "boolean",
|
|
121
|
+
"default": true,
|
|
122
|
+
"markdownDescription": "Switches to the \"Output\" tab whenever an error occurs in the language server.",
|
|
123
|
+
"scope": "window"
|
|
124
|
+
},
|
|
125
|
+
"apollographql.display.showRunInStudioButton": {
|
|
126
|
+
"type": "boolean",
|
|
127
|
+
"default": true,
|
|
128
|
+
"markdownDescription": "Show a \"Run in Studio\" button to the right of Operation Signatures.",
|
|
129
|
+
"scope": "window"
|
|
60
130
|
}
|
|
61
131
|
}
|
|
62
132
|
},
|
|
@@ -84,9 +154,10 @@
|
|
|
84
154
|
"injectTo": [
|
|
85
155
|
"source.js",
|
|
86
156
|
"source.ts",
|
|
87
|
-
"source.
|
|
157
|
+
"source.jsx",
|
|
88
158
|
"source.tsx",
|
|
89
|
-
"source.vue"
|
|
159
|
+
"source.vue",
|
|
160
|
+
"source.svelte"
|
|
90
161
|
],
|
|
91
162
|
"scopeName": "inline.graphql",
|
|
92
163
|
"path": "./syntaxes/graphql.js.json",
|
|
@@ -104,6 +175,16 @@
|
|
|
104
175
|
"meta.embedded.block.graphql": "graphql"
|
|
105
176
|
}
|
|
106
177
|
},
|
|
178
|
+
{
|
|
179
|
+
"injectTo": [
|
|
180
|
+
"source.lua"
|
|
181
|
+
],
|
|
182
|
+
"scopeName": "inline.graphql.lua",
|
|
183
|
+
"path": "./syntaxes/graphql.lua.json",
|
|
184
|
+
"embeddedLanguages": {
|
|
185
|
+
"meta.embedded.block.graphql": "graphql"
|
|
186
|
+
}
|
|
187
|
+
},
|
|
107
188
|
{
|
|
108
189
|
"injectTo": [
|
|
109
190
|
"source.ruby"
|
|
@@ -166,6 +247,5 @@
|
|
|
166
247
|
"galleryBanner": {
|
|
167
248
|
"color": "#1d127d",
|
|
168
249
|
"theme": "dark"
|
|
169
|
-
}
|
|
170
|
-
"gitHead": "7f77a11e5c3123137af9235b4a32ac76ec1aad39"
|
|
250
|
+
}
|
|
171
251
|
}
|
package/renovate.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": ["apollo-open-source"],
|
|
3
|
+
"dependencyDashboard": true,
|
|
4
|
+
"packageRules": [
|
|
5
|
+
{
|
|
6
|
+
"groupName": "all @types",
|
|
7
|
+
"groupSlug": "all-types",
|
|
8
|
+
"matchPackagePatterns": ["@types/*"]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"groupName": "all devDependencies",
|
|
12
|
+
"groupSlug": "all-dev",
|
|
13
|
+
"matchPackagePatterns": ["*"],
|
|
14
|
+
"matchDepTypes": ["devDependencies"]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"groupName": "all dependencies - patch updates",
|
|
18
|
+
"groupSlug": "all-patch",
|
|
19
|
+
"matchPackagePatterns": ["*"],
|
|
20
|
+
"matchUpdateTypes": ["patch"]
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import StatusBar from "../statusBar";
|
|
1
|
+
// import StatusBar from "../statusBar";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// TODO (jgzuke) disable this until we migrate away from `vscode`.
|
|
4
|
+
// https://code.visualstudio.com/api/working-with-extensions/testing-extension#migrating-from-vscode
|
|
5
|
+
describe.skip("statusBar", () => {
|
|
4
6
|
it("only shows loaded state when it's supposed to", () => {
|
|
5
|
-
const statusBar = new StatusBar({ hasActiveTextEditor: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
statusBar.
|
|
9
|
-
expect(statusBar.statusBarItem.text).toEqual(StatusBar.loadedStateText);
|
|
7
|
+
// const statusBar = new StatusBar({ hasActiveTextEditor: true });
|
|
8
|
+
// expect(statusBar.statusBarItem.text).toEqual(StatusBar.loadingStateText);
|
|
9
|
+
// statusBar.showLoadedState({ hasActiveTextEditor: true });
|
|
10
|
+
// expect(statusBar.statusBarItem.text).toEqual(StatusBar.loadedStateText);
|
|
10
11
|
});
|
|
11
12
|
});
|
package/src/debug.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OutputChannel } from "vscode";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* for errors (and other logs in debug mode) we want to print
|
|
@@ -10,10 +10,7 @@ const createAndTrimStackTrace = () => {
|
|
|
10
10
|
let stack: string | undefined = new Error().stack;
|
|
11
11
|
// remove the lines in the stack from _this_ function and the caller (in this file) and shorten the trace
|
|
12
12
|
return stack && stack.split("\n").length > 2
|
|
13
|
-
? stack
|
|
14
|
-
.split("\n")
|
|
15
|
-
.slice(3, 7)
|
|
16
|
-
.join("\n")
|
|
13
|
+
? stack.split("\n").slice(3, 7).join("\n")
|
|
17
14
|
: stack;
|
|
18
15
|
};
|
|
19
16
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Agent as HttpAgent } from "http";
|
|
2
|
+
import { Agent as HttpsAgent } from "https";
|
|
3
|
+
|
|
4
|
+
export type RequestAgent = HttpAgent | HttpsAgent;
|
|
5
|
+
|
|
6
|
+
export type ReferrerPolicy =
|
|
7
|
+
| ""
|
|
8
|
+
| "no-referrer"
|
|
9
|
+
| "no-referrer-when-downgrade"
|
|
10
|
+
| "same-origin"
|
|
11
|
+
| "origin"
|
|
12
|
+
| "strict-origin"
|
|
13
|
+
| "origin-when-cross-origin"
|
|
14
|
+
| "strict-origin-when-cross-origin"
|
|
15
|
+
| "unsafe-url";
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
default as fetch,
|
|
19
|
+
Request,
|
|
20
|
+
Response,
|
|
21
|
+
Headers,
|
|
22
|
+
ResponseInit,
|
|
23
|
+
BodyInit,
|
|
24
|
+
RequestInfo,
|
|
25
|
+
HeadersInit,
|
|
26
|
+
Body,
|
|
27
|
+
RequestInit,
|
|
28
|
+
RequestMode,
|
|
29
|
+
RequestCredentials,
|
|
30
|
+
RequestCache,
|
|
31
|
+
RequestRedirect,
|
|
32
|
+
} from "node-fetch";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
declare function fetch(
|
|
2
|
+
input?: RequestInfo,
|
|
3
|
+
init?: RequestInit
|
|
4
|
+
): Promise<Response>;
|
|
5
|
+
|
|
6
|
+
declare interface GlobalFetch {
|
|
7
|
+
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare interface WindowOrWorkerGlobalScope {
|
|
11
|
+
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type RequestInfo = import("./fetch").RequestInfo;
|
|
15
|
+
type Headers = import("./fetch").Headers;
|
|
16
|
+
type HeadersInit = import("./fetch").HeadersInit;
|
|
17
|
+
type Body = import("./fetch").Body;
|
|
18
|
+
type Request = import("./fetch").Request;
|
|
19
|
+
type RequestAgent = import("./fetch").RequestAgent;
|
|
20
|
+
type RequestInit = import("./fetch").RequestInit;
|
|
21
|
+
type RequestMode = import("./fetch").RequestMode;
|
|
22
|
+
type RequestCredentials = import("./fetch").RequestCredentials;
|
|
23
|
+
type RequestCache = import("./fetch").RequestCache;
|
|
24
|
+
type RequestRedirect = import("./fetch").RequestRedirect;
|
|
25
|
+
type ReferrerPolicy = import("./fetch").ReferrerPolicy;
|
|
26
|
+
type Response = import("./fetch").Response;
|
|
27
|
+
type ResponseInit = import("./fetch").ResponseInit;
|
|
28
|
+
type BodyInit = import("./fetch").BodyInit;
|
|
29
|
+
type URLSearchParams = import("./url").URLSearchParams;
|
|
30
|
+
type URLSearchParamsInit = import("./url").URLSearchParamsInit;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { URLSearchParams } from "url";
|
|
2
|
+
export { URL, URLSearchParams } from "url";
|
|
3
|
+
|
|
4
|
+
export type URLSearchParamsInit =
|
|
5
|
+
| URLSearchParams
|
|
6
|
+
| string
|
|
7
|
+
| { [key: string]: Object | Object[] | undefined }
|
|
8
|
+
| Iterable<[string, Object]>
|
|
9
|
+
| Array<[string, Object]>;
|
package/src/env/index.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference lib="esnext.array" />
|
|
2
|
+
import "core-js/features/array/flat";
|
|
3
|
+
import "core-js/features/array/flat-map";
|
|
4
|
+
|
|
5
|
+
// The built-in Array.flat typings don't contain an overload for ReadonlyArray<U>[],
|
|
6
|
+
// which means the return type is inferred to be any[] instead of U[], hence this augmentation.
|
|
7
|
+
declare global {
|
|
8
|
+
interface Array<T> {
|
|
9
|
+
/**
|
|
10
|
+
* Returns a new array with all sub-array elements concatenated into it recursively up to the
|
|
11
|
+
* specified depth.
|
|
12
|
+
*
|
|
13
|
+
* @param depth The maximum recursion depth
|
|
14
|
+
*/
|
|
15
|
+
flat<U>(this: ReadonlyArray<U>[], depth?: 1): U[];
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/extension.ts
CHANGED
|
@@ -9,14 +9,17 @@ import {
|
|
|
9
9
|
commands,
|
|
10
10
|
QuickPickItem,
|
|
11
11
|
Disposable,
|
|
12
|
-
OutputChannel
|
|
12
|
+
OutputChannel,
|
|
13
|
+
MarkdownString,
|
|
14
|
+
Range,
|
|
13
15
|
} from "vscode";
|
|
14
16
|
import StatusBar from "./statusBar";
|
|
15
17
|
import { getLanguageServerClient } from "./languageServerClient";
|
|
16
|
-
import {
|
|
18
|
+
import { NotificationType } from "vscode-languageclient";
|
|
19
|
+
import type { EngineDecoration, LanguageClient } from "./messages";
|
|
17
20
|
import {
|
|
18
21
|
printNoFileOpenMessage,
|
|
19
|
-
printStatsToClientOutputChannel
|
|
22
|
+
printStatsToClientOutputChannel,
|
|
20
23
|
} from "./utils";
|
|
21
24
|
import { Debug } from "./debug";
|
|
22
25
|
|
|
@@ -43,7 +46,7 @@ function isError(response: any): response is ErrorShape {
|
|
|
43
46
|
|
|
44
47
|
export function activate(context: ExtensionContext) {
|
|
45
48
|
const serverModule = context.asAbsolutePath(
|
|
46
|
-
join("
|
|
49
|
+
join("lib/language-server", "server.js")
|
|
47
50
|
);
|
|
48
51
|
|
|
49
52
|
// Initialize language client
|
|
@@ -52,7 +55,7 @@ export function activate(context: ExtensionContext) {
|
|
|
52
55
|
|
|
53
56
|
// Initialize disposables
|
|
54
57
|
statusBar = new StatusBar({
|
|
55
|
-
hasActiveTextEditor: Boolean(window.activeTextEditor)
|
|
58
|
+
hasActiveTextEditor: Boolean(window.activeTextEditor),
|
|
56
59
|
});
|
|
57
60
|
outputChannel = window.createOutputChannel("Apollo GraphQL");
|
|
58
61
|
Debug.SetOutputConsole(outputChannel);
|
|
@@ -68,7 +71,7 @@ export function activate(context: ExtensionContext) {
|
|
|
68
71
|
|
|
69
72
|
// Once client is ready, we can send messages and add listeners for various notifications
|
|
70
73
|
client.onReady().then(() => {
|
|
71
|
-
client.onNotification(serverDebugMessage, message => {
|
|
74
|
+
client.onNotification(serverDebugMessage, (message) => {
|
|
72
75
|
switch (message.type) {
|
|
73
76
|
case "info":
|
|
74
77
|
Debug.info(message.message, message.stack);
|
|
@@ -103,7 +106,7 @@ export function activate(context: ExtensionContext) {
|
|
|
103
106
|
client.outputChannel.show();
|
|
104
107
|
});
|
|
105
108
|
|
|
106
|
-
client.onNotification("apollographql/statsLoaded", params => {
|
|
109
|
+
client.onNotification("apollographql/statsLoaded", (params) => {
|
|
107
110
|
printStatsToClientOutputChannel(client, params, version);
|
|
108
111
|
client.outputChannel.show();
|
|
109
112
|
});
|
|
@@ -118,14 +121,14 @@ export function activate(context: ExtensionContext) {
|
|
|
118
121
|
if (isError(response)) {
|
|
119
122
|
statusBar.showWarningState({
|
|
120
123
|
hasActiveTextEditor,
|
|
121
|
-
tooltip: "Configuration Error"
|
|
124
|
+
tooltip: "Configuration Error",
|
|
122
125
|
});
|
|
123
126
|
outputChannel.append(response.stack);
|
|
124
127
|
|
|
125
128
|
const infoButtonText = "More Info";
|
|
126
129
|
window
|
|
127
130
|
.showInformationMessage(response.message, infoButtonText)
|
|
128
|
-
.then(clicked => {
|
|
131
|
+
.then((clicked) => {
|
|
129
132
|
if (clicked === infoButtonText) {
|
|
130
133
|
outputChannel.show();
|
|
131
134
|
}
|
|
@@ -134,7 +137,7 @@ export function activate(context: ExtensionContext) {
|
|
|
134
137
|
if (response.length === 0) {
|
|
135
138
|
statusBar.showWarningState({
|
|
136
139
|
hasActiveTextEditor,
|
|
137
|
-
tooltip: "No apollo.config.js file found"
|
|
140
|
+
tooltip: "No apollo.config.js file found",
|
|
138
141
|
});
|
|
139
142
|
} else {
|
|
140
143
|
statusBar.showLoadedState({ hasActiveTextEditor });
|
|
@@ -158,12 +161,12 @@ export function activate(context: ExtensionContext) {
|
|
|
158
161
|
|
|
159
162
|
// For some reason, non-strings can only be sent in one direction. For now, messages
|
|
160
163
|
// coming from the language server just need to be stringified and parsed.
|
|
161
|
-
client.onNotification("apollographql/tagsLoaded", params => {
|
|
164
|
+
client.onNotification("apollographql/tagsLoaded", (params) => {
|
|
162
165
|
const [serviceID, tags]: [string, string[]] = JSON.parse(params);
|
|
163
|
-
const items = tags.map(tag => ({
|
|
166
|
+
const items = tags.map((tag) => ({
|
|
164
167
|
label: tag,
|
|
165
168
|
description: "",
|
|
166
|
-
detail: serviceID
|
|
169
|
+
detail: serviceID,
|
|
167
170
|
}));
|
|
168
171
|
|
|
169
172
|
schemaTagItems = [...items, ...schemaTagItems];
|
|
@@ -178,9 +181,9 @@ export function activate(context: ExtensionContext) {
|
|
|
178
181
|
|
|
179
182
|
let currentLoadingResolve: Map<number, () => void> = new Map();
|
|
180
183
|
|
|
181
|
-
client.onNotification("apollographql/loadingComplete", token => {
|
|
184
|
+
client.onNotification("apollographql/loadingComplete", (token) => {
|
|
182
185
|
statusBar.showLoadedState({
|
|
183
|
-
hasActiveTextEditor: Boolean(window.activeTextEditor)
|
|
186
|
+
hasActiveTextEditor: Boolean(window.activeTextEditor),
|
|
184
187
|
});
|
|
185
188
|
const inMap = currentLoadingResolve.get(token);
|
|
186
189
|
if (inMap) {
|
|
@@ -194,46 +197,112 @@ export function activate(context: ExtensionContext) {
|
|
|
194
197
|
{
|
|
195
198
|
location: ProgressLocation.Notification,
|
|
196
199
|
title: message,
|
|
197
|
-
cancellable: false
|
|
200
|
+
cancellable: false,
|
|
198
201
|
},
|
|
199
202
|
() => {
|
|
200
|
-
return new Promise<void>(resolve => {
|
|
203
|
+
return new Promise<void>((resolve) => {
|
|
201
204
|
currentLoadingResolve.set(token, resolve);
|
|
202
205
|
});
|
|
203
206
|
}
|
|
204
207
|
);
|
|
205
208
|
});
|
|
206
209
|
|
|
207
|
-
const
|
|
208
|
-
|
|
210
|
+
const runIconOnDiskPath = Uri.file(
|
|
211
|
+
join(context.extensionPath, "images", "IconRun.svg")
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
const textDecorationType = window.createTextEditorDecorationType({});
|
|
215
|
+
const runGlyphDecorationType = window.createTextEditorDecorationType({});
|
|
216
|
+
let latestDecorations: EngineDecoration[] | undefined = undefined;
|
|
209
217
|
|
|
210
218
|
const updateDecorations = () => {
|
|
211
|
-
if (window.activeTextEditor &&
|
|
219
|
+
if (window.activeTextEditor && latestDecorations) {
|
|
212
220
|
const editor = window.activeTextEditor!;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
221
|
+
|
|
222
|
+
const decorationsForDocument = latestDecorations.filter(
|
|
223
|
+
(decoration) =>
|
|
224
|
+
decoration.document ===
|
|
225
|
+
window.activeTextEditor!.document.uri.toString()
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
const textDecorations = decorationsForDocument.flatMap(
|
|
229
|
+
(decoration): DecorationOptions | DecorationOptions[] => {
|
|
230
|
+
if (decoration.type !== "text") {
|
|
231
|
+
return [];
|
|
232
|
+
}
|
|
233
|
+
|
|
218
234
|
return {
|
|
219
|
-
range: editor.document.lineAt(
|
|
235
|
+
range: editor.document.lineAt(decoration.range.start.line).range,
|
|
220
236
|
renderOptions: {
|
|
221
237
|
after: {
|
|
222
|
-
contentText:
|
|
223
|
-
textDecoration: "none; padding-left: 15px; opacity: .5"
|
|
224
|
-
}
|
|
225
|
-
}
|
|
238
|
+
contentText: decoration.message,
|
|
239
|
+
textDecoration: "none; padding-left: 15px; opacity: .5",
|
|
240
|
+
},
|
|
241
|
+
},
|
|
226
242
|
};
|
|
227
|
-
}
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
const runGlyphDecorations = decorationsForDocument.flatMap(
|
|
247
|
+
(decoration): DecorationOptions | DecorationOptions[] => {
|
|
248
|
+
if (decoration.type !== "runGlyph") {
|
|
249
|
+
return [];
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const hoverMessage =
|
|
253
|
+
decoration.hoverMessage === undefined
|
|
254
|
+
? undefined
|
|
255
|
+
: new MarkdownString(decoration.hoverMessage);
|
|
256
|
+
if (hoverMessage) {
|
|
257
|
+
hoverMessage.isTrusted = true;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const endOfLinePosition = editor.document.lineAt(
|
|
261
|
+
decoration.range.start.line
|
|
262
|
+
).range.end;
|
|
263
|
+
return {
|
|
264
|
+
// Hover range of just the end of the line (and the icon) so the hover shows above the icon,
|
|
265
|
+
// not over at the start of the line
|
|
266
|
+
range: new Range(endOfLinePosition, endOfLinePosition),
|
|
267
|
+
renderOptions: {
|
|
268
|
+
after: {
|
|
269
|
+
contentIconPath: runIconOnDiskPath,
|
|
270
|
+
textDecoration:
|
|
271
|
+
"none; border-radius: .20rem; margin-left: 8px; text-align: center;",
|
|
272
|
+
backgroundColor: "#2075D6",
|
|
273
|
+
width: "18px",
|
|
274
|
+
height: "18px",
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
hoverMessage,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
);
|
|
228
281
|
|
|
229
|
-
window.activeTextEditor!.setDecorations(
|
|
282
|
+
window.activeTextEditor!.setDecorations(
|
|
283
|
+
textDecorationType,
|
|
284
|
+
textDecorations
|
|
285
|
+
);
|
|
286
|
+
if (
|
|
287
|
+
workspace
|
|
288
|
+
.getConfiguration("apollographql")
|
|
289
|
+
.get("display.showRunInStudioButton")
|
|
290
|
+
) {
|
|
291
|
+
window.activeTextEditor!.setDecorations(
|
|
292
|
+
runGlyphDecorationType,
|
|
293
|
+
runGlyphDecorations
|
|
294
|
+
);
|
|
295
|
+
}
|
|
230
296
|
}
|
|
231
297
|
};
|
|
232
298
|
|
|
233
|
-
client.onNotification(
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
299
|
+
client.onNotification(
|
|
300
|
+
"apollographql/engineDecorations",
|
|
301
|
+
({ decorations }) => {
|
|
302
|
+
latestDecorations = decorations;
|
|
303
|
+
updateDecorations();
|
|
304
|
+
}
|
|
305
|
+
);
|
|
237
306
|
|
|
238
307
|
window.onDidChangeActiveTextEditor(() => {
|
|
239
308
|
updateDecorations();
|
|
@@ -243,7 +312,7 @@ export function activate(context: ExtensionContext) {
|
|
|
243
312
|
provideTextDocumentContent(uri: Uri) {
|
|
244
313
|
// the schema source is provided inside the URI, just return that here
|
|
245
314
|
return uri.query;
|
|
246
|
-
}
|
|
315
|
+
},
|
|
247
316
|
});
|
|
248
317
|
});
|
|
249
318
|
}
|