vscode-apollo 2.3.4 → 2.3.6
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/.github/workflows/E2E.yml +5 -0
- package/CHANGELOG.md +12 -0
- package/package.json +5 -1
- package/schemas/supergraph_config_schema.json +119 -0
- package/src/__e2e__/runTests.js +1 -0
- package/src/language-server/config/cache-busting-resolver.js +70 -7
- package/src/language-server/config/cache-busting-resolver.types.ts +20 -2
- package/src/language-server/config/loadTsConfig.ts +12 -4
|
@@ -8,6 +8,9 @@ jobs:
|
|
|
8
8
|
test:
|
|
9
9
|
name: Run E2E tests
|
|
10
10
|
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
version: ["1.90.0", "stable", "insiders"]
|
|
11
14
|
steps:
|
|
12
15
|
- run: sudo apt update && sudo apt install -y libasound2 libgbm1 libgtk-3-0 libnss3 xvfb expect
|
|
13
16
|
- uses: actions/checkout@v4
|
|
@@ -25,3 +28,5 @@ jobs:
|
|
|
25
28
|
expect eof
|
|
26
29
|
EOF
|
|
27
30
|
- run: xvfb-run -a npm run test:extension
|
|
31
|
+
env:
|
|
32
|
+
VSCODE_VERSION: "${{ matrix.version }}"
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 2.3.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#216](https://github.com/apollographql/vscode-graphql/pull/216) [`1add31e0`](https://github.com/apollographql/vscode-graphql/commit/1add31e0e9bc2da92ea7c3a1c65206cc5d95bb68) Thanks [@phryneas](https://github.com/phryneas)! - Add JSON schema for `supergraph.yaml`.
|
|
8
|
+
|
|
9
|
+
## 2.3.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#226](https://github.com/apollographql/vscode-graphql/pull/226) [`57c51c81`](https://github.com/apollographql/vscode-graphql/commit/57c51c81ec56d68c2226f0b169ed849fcbdaad55) Thanks [@yesmeck](https://github.com/yesmeck)! - Fixes config files being unable to load in old VSCode versions
|
|
14
|
+
|
|
3
15
|
## 2.3.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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": "2.3.
|
|
5
|
+
"version": "2.3.6",
|
|
6
6
|
"referenceID": "87197759-7617-40d0-b32e-46d378e907c7",
|
|
7
7
|
"author": "Apollo GraphQL <opensource@apollographql.com>",
|
|
8
8
|
"license": "MIT",
|
|
@@ -258,6 +258,10 @@
|
|
|
258
258
|
{
|
|
259
259
|
"fileMatch": "apollo.config.yaml",
|
|
260
260
|
"url": "./schemas/apollo.config.schema.json"
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
"fileMatch": "supergraph.yaml",
|
|
264
|
+
"url": "./schemas/supergraph_config_schema.json"
|
|
261
265
|
}
|
|
262
266
|
],
|
|
263
267
|
"commands": [
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "SupergraphConfig",
|
|
4
|
+
"description": "The configuration for a single supergraph composed of multiple subgraphs.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": [
|
|
7
|
+
"subgraphs"
|
|
8
|
+
],
|
|
9
|
+
"properties": {
|
|
10
|
+
"federation_version": {
|
|
11
|
+
"anyOf": [
|
|
12
|
+
{
|
|
13
|
+
"$ref": "#/definitions/FederationVersion"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"type": "null"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
"subgraphs": {
|
|
21
|
+
"type": "object",
|
|
22
|
+
"additionalProperties": {
|
|
23
|
+
"$ref": "#/definitions/SubgraphConfig"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"definitions": {
|
|
28
|
+
"FederationVersion": {
|
|
29
|
+
"pattern": "^(1|2|=2\\.\\d+\\.\\d+.*)$"
|
|
30
|
+
},
|
|
31
|
+
"SchemaSource": {
|
|
32
|
+
"description": "Options for getting SDL: the graph registry, a file, or an introspection URL.\n\nNOTE: Introspection strips all comments and directives from the SDL.",
|
|
33
|
+
"anyOf": [
|
|
34
|
+
{
|
|
35
|
+
"type": "object",
|
|
36
|
+
"required": [
|
|
37
|
+
"file"
|
|
38
|
+
],
|
|
39
|
+
"properties": {
|
|
40
|
+
"file": {
|
|
41
|
+
"type": "string"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"type": "object",
|
|
47
|
+
"required": [
|
|
48
|
+
"subgraph_url"
|
|
49
|
+
],
|
|
50
|
+
"properties": {
|
|
51
|
+
"introspection_headers": {
|
|
52
|
+
"type": [
|
|
53
|
+
"object",
|
|
54
|
+
"null"
|
|
55
|
+
],
|
|
56
|
+
"additionalProperties": {
|
|
57
|
+
"type": "string"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"subgraph_url": {
|
|
61
|
+
"type": "string",
|
|
62
|
+
"format": "uri"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"type": "object",
|
|
68
|
+
"required": [
|
|
69
|
+
"graphref",
|
|
70
|
+
"subgraph"
|
|
71
|
+
],
|
|
72
|
+
"properties": {
|
|
73
|
+
"graphref": {
|
|
74
|
+
"type": "string"
|
|
75
|
+
},
|
|
76
|
+
"subgraph": {
|
|
77
|
+
"type": "string"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"type": "object",
|
|
83
|
+
"required": [
|
|
84
|
+
"sdl"
|
|
85
|
+
],
|
|
86
|
+
"properties": {
|
|
87
|
+
"sdl": {
|
|
88
|
+
"type": "string"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
"SubgraphConfig": {
|
|
95
|
+
"description": "Config for a single [subgraph](https://www.apollographql.com/docs/federation/subgraphs/)",
|
|
96
|
+
"type": "object",
|
|
97
|
+
"required": [
|
|
98
|
+
"schema"
|
|
99
|
+
],
|
|
100
|
+
"properties": {
|
|
101
|
+
"routing_url": {
|
|
102
|
+
"description": "The routing URL for the subgraph. This will appear in supergraph SDL and instructs the graph router to send all requests for this subgraph to this URL.",
|
|
103
|
+
"type": [
|
|
104
|
+
"string",
|
|
105
|
+
"null"
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
"schema": {
|
|
109
|
+
"description": "The location of the subgraph's SDL",
|
|
110
|
+
"allOf": [
|
|
111
|
+
{
|
|
112
|
+
"$ref": "#/definitions/SchemaSource"
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
package/src/__e2e__/runTests.js
CHANGED
|
@@ -28,6 +28,7 @@ async function main() {
|
|
|
28
28
|
const exitCode = await runTests({
|
|
29
29
|
extensionDevelopmentPath,
|
|
30
30
|
extensionTestsPath,
|
|
31
|
+
version: process.env.VSCODE_VERSION || "stable",
|
|
31
32
|
launchArgs: [
|
|
32
33
|
"--disable-extensions",
|
|
33
34
|
`${extensionDevelopmentPath}/sampleWorkspace/sampleWorkspace.code-workspace`,
|
|
@@ -1,7 +1,62 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
const { pathToFileURL } = require("node:url");
|
|
3
3
|
|
|
4
|
-
/** @import { ResolveContext, ResolutionResult, LoadResult, ImportContext } from "./cache-busting-resolver.types" */
|
|
4
|
+
/** @import { ResolveContext, ResolutionResult, LoadResult, ImportContext, ImportAttributes, ImportAssertions, LegacyResolveContext, LegacyImportContext, Format } from "./cache-busting-resolver.types" */
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* importAssertions was renamed to importAttributes after following versions of Node.js.
|
|
8
|
+
* Once we hit a minimum of v1.92 of VSCode, we can remove the legacy check and
|
|
9
|
+
* use `importAttributes` directly.
|
|
10
|
+
*
|
|
11
|
+
* - v21.0.0
|
|
12
|
+
* - v20.10.0
|
|
13
|
+
* - v18.19.0
|
|
14
|
+
*
|
|
15
|
+
* @see https://github.com/apollographql/vscode-graphql/issues/225
|
|
16
|
+
* @see https://nodejs.org/docs/latest/api/module.html#resolvespecifier-context-nextresolve
|
|
17
|
+
*
|
|
18
|
+
* @param {ResolveContext|ImportContext|LegacyResolveContext|LegacyImportContext} context
|
|
19
|
+
* @returns {context is ResolveContext|ImportContext}
|
|
20
|
+
*/
|
|
21
|
+
function isImportAttributesAvailable(context) {
|
|
22
|
+
return "importAttributes" in context;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {ResolveContext|ImportContext} context
|
|
27
|
+
* @returns {"importAttributes"|"importAssertions"}
|
|
28
|
+
*/
|
|
29
|
+
function resolveImportAttributesKeyName(context) {
|
|
30
|
+
if (isImportAttributesAvailable(context)) {
|
|
31
|
+
return "importAttributes";
|
|
32
|
+
}
|
|
33
|
+
return "importAssertions";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @param {ResolveContext|ImportContext|LegacyResolveContext|LegacyImportContext} context
|
|
38
|
+
* @returns {ImportAttributes|ImportAssertions}
|
|
39
|
+
*/
|
|
40
|
+
function resolveImportAttributes(context) {
|
|
41
|
+
if (isImportAttributesAvailable(context)) {
|
|
42
|
+
return context.importAttributes;
|
|
43
|
+
}
|
|
44
|
+
return context.importAssertions;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @param {ImportAttributes|ImportAssertions} importAttributes
|
|
49
|
+
* @returns {Format|null}
|
|
50
|
+
*/
|
|
51
|
+
function resolveConfigFormat(importAttributes) {
|
|
52
|
+
const [as, format] = importAttributes.as
|
|
53
|
+
? importAttributes.as.split(":")
|
|
54
|
+
: [];
|
|
55
|
+
if (as === "cachebust" && format) {
|
|
56
|
+
return /** @type {Format} */ (format);
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
5
60
|
|
|
6
61
|
/**
|
|
7
62
|
* @param {string} specifier
|
|
@@ -21,14 +76,16 @@ function bustFileName(specifier) {
|
|
|
21
76
|
* @returns {Promise<ResolutionResult>}
|
|
22
77
|
*/
|
|
23
78
|
async function resolve(specifier, context, nextResolve) {
|
|
24
|
-
|
|
79
|
+
const importAttributes = resolveImportAttributes(context);
|
|
80
|
+
const format = resolveConfigFormat(importAttributes);
|
|
81
|
+
if (!format) {
|
|
25
82
|
return nextResolve(specifier, context);
|
|
26
83
|
}
|
|
27
84
|
// no need to resolve at all, we have all necessary information
|
|
28
85
|
return {
|
|
29
86
|
url: bustFileName(specifier),
|
|
30
|
-
format
|
|
31
|
-
|
|
87
|
+
format,
|
|
88
|
+
[resolveImportAttributesKeyName(context)]: importAttributes,
|
|
32
89
|
shortCircuit: true,
|
|
33
90
|
};
|
|
34
91
|
}
|
|
@@ -41,13 +98,19 @@ async function resolve(specifier, context, nextResolve) {
|
|
|
41
98
|
* @returns {Promise<LoadResult>}
|
|
42
99
|
*/
|
|
43
100
|
async function load(url, context, nextLoad) {
|
|
44
|
-
|
|
101
|
+
const importAttributes = resolveImportAttributes(context);
|
|
102
|
+
const format = resolveConfigFormat(importAttributes);
|
|
103
|
+
if (!format) {
|
|
45
104
|
return nextLoad(url, context);
|
|
46
105
|
}
|
|
106
|
+
const contents =
|
|
107
|
+
"contents" in importAttributes
|
|
108
|
+
? importAttributes.contents
|
|
109
|
+
: Object.keys(importAttributes).find((key) => key != "as");
|
|
47
110
|
return {
|
|
48
|
-
format
|
|
111
|
+
format,
|
|
49
112
|
shortCircuit: true,
|
|
50
|
-
source:
|
|
113
|
+
source: /** @type {string} */ (contents),
|
|
51
114
|
};
|
|
52
115
|
}
|
|
53
116
|
|
|
@@ -2,13 +2,20 @@ import { pathToFileURL } from "node:url";
|
|
|
2
2
|
|
|
3
3
|
export type ImportAttributes =
|
|
4
4
|
| {
|
|
5
|
-
as:
|
|
5
|
+
as: `cachebust:${Format}`;
|
|
6
6
|
contents: string;
|
|
7
7
|
format: Format;
|
|
8
8
|
}
|
|
9
9
|
| { as?: undefined };
|
|
10
10
|
|
|
11
|
-
type
|
|
11
|
+
export type ImportAssertions =
|
|
12
|
+
| {
|
|
13
|
+
as: `cachebust:${Format}`;
|
|
14
|
+
[key: string]: string;
|
|
15
|
+
}
|
|
16
|
+
| { as?: undefined };
|
|
17
|
+
|
|
18
|
+
export type Format =
|
|
12
19
|
| "builtin"
|
|
13
20
|
| "commonjs"
|
|
14
21
|
| "json"
|
|
@@ -17,12 +24,23 @@ type Format =
|
|
|
17
24
|
| null
|
|
18
25
|
| undefined;
|
|
19
26
|
|
|
27
|
+
export interface LegacyResolveContext {
|
|
28
|
+
conditions: string[];
|
|
29
|
+
importAssertions: ImportAssertions;
|
|
30
|
+
parentURL?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
20
33
|
export interface ResolveContext {
|
|
21
34
|
conditions: string[];
|
|
22
35
|
importAttributes: ImportAttributes;
|
|
23
36
|
parentURL?: string;
|
|
24
37
|
}
|
|
25
38
|
|
|
39
|
+
export interface LegacyImportContext {
|
|
40
|
+
conditions: string[];
|
|
41
|
+
importAssertions: ImportAssertions;
|
|
42
|
+
format: Format;
|
|
43
|
+
}
|
|
26
44
|
export interface ImportContext {
|
|
27
45
|
conditions: string[];
|
|
28
46
|
importAttributes: ImportAttributes;
|
|
@@ -3,16 +3,19 @@ import { dirname, extname } from "node:path";
|
|
|
3
3
|
import typescript from "typescript";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
5
5
|
import { register } from "node:module";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
ImportAssertions,
|
|
8
|
+
ImportAttributes,
|
|
9
|
+
} from "./cache-busting-resolver.types";
|
|
7
10
|
// implementation based on https://github.com/cosmiconfig/cosmiconfig/blob/a5a842547c13392ebb89a485b9e56d9f37e3cbd3/src/loaders.ts
|
|
8
11
|
// Copyright (c) 2015 David Clark licensed MIT. Full license can be found here:
|
|
9
12
|
// https://github.com/cosmiconfig/cosmiconfig/blob/a5a842547c13392ebb89a485b9e56d9f37e3cbd3/LICENSE
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
try {
|
|
12
15
|
register(
|
|
13
16
|
pathToFileURL(require.resolve("./config/cache-busting-resolver.js")),
|
|
14
17
|
);
|
|
15
|
-
}
|
|
18
|
+
} catch {
|
|
16
19
|
register(pathToFileURL(require.resolve("./cache-busting-resolver.js")));
|
|
17
20
|
}
|
|
18
21
|
|
|
@@ -114,10 +117,15 @@ async function loadCachebustedJs(
|
|
|
114
117
|
// @ts-ignore
|
|
115
118
|
{
|
|
116
119
|
with: {
|
|
117
|
-
as:
|
|
120
|
+
as: `cachebust:${type}`,
|
|
118
121
|
contents,
|
|
119
122
|
format: type,
|
|
120
123
|
} satisfies ImportAttributes,
|
|
124
|
+
assert: {
|
|
125
|
+
as: `cachebust:${type}`,
|
|
126
|
+
contents,
|
|
127
|
+
format: type,
|
|
128
|
+
} satisfies ImportAssertions,
|
|
121
129
|
}
|
|
122
130
|
)
|
|
123
131
|
).default;
|