vscode-apollo 2.2.0 → 2.3.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.
Files changed (38) hide show
  1. package/.circleci/config.yml +1 -1
  2. package/.github/workflows/build-prs.yml +55 -0
  3. package/.github/workflows/release.yml +1 -1
  4. package/.gitleaks.toml +10 -3
  5. package/.vscodeignore +0 -1
  6. package/CHANGELOG.md +26 -0
  7. package/README.md +68 -52
  8. package/package.json +31 -3
  9. package/renovate.json +5 -5
  10. package/sampleWorkspace/httpSchema/apollo.config.ts +2 -0
  11. package/sampleWorkspace/httpSchema/self-signed.crt +22 -0
  12. package/sampleWorkspace/httpSchema/self-signed.key +28 -0
  13. package/sampleWorkspace/localSchemaArray/apollo.config.json +9 -0
  14. package/sampleWorkspace/rover/apollo.config.yaml +2 -0
  15. package/sampleWorkspace/rover/supergraph.yaml +0 -0
  16. package/schemas/apollo.config.schema.json +184 -0
  17. package/src/__e2e__/mockServer.js +37 -11
  18. package/src/__e2e__/mocks.js +11 -7
  19. package/src/__e2e__/runTests.js +8 -6
  20. package/src/build.js +53 -1
  21. package/src/language-server/__e2e__/studioGraph.e2e.ts +4 -3
  22. package/src/language-server/config/__tests__/loadConfig.ts +35 -2
  23. package/src/language-server/config/cache-busting-resolver.js +65 -0
  24. package/src/language-server/config/cache-busting-resolver.types.ts +45 -0
  25. package/src/language-server/config/config.ts +136 -60
  26. package/src/language-server/config/loadConfig.ts +27 -6
  27. package/src/language-server/config/loadTsConfig.ts +74 -38
  28. package/src/language-server/project/base.ts +8 -8
  29. package/src/language-server/project/rover/DocumentSynchronization.ts +44 -22
  30. package/src/language-server/project/rover/project.ts +6 -0
  31. package/src/language-server/providers/schema/endpoint.ts +15 -8
  32. package/src/language-server/server.ts +8 -7
  33. package/src/language-server/workspace.ts +2 -5
  34. package/src/languageServerClient.ts +3 -1
  35. package/syntaxes/graphql.json +2 -2
  36. package/sampleWorkspace/localSchemaArray/apollo.config.js +0 -12
  37. package/sampleWorkspace/rover/apollo.config.js +0 -3
  38. /package/sampleWorkspace/localSchema/{apollo.config.js → apollo.config.ts} +0 -0
@@ -17,7 +17,16 @@ import { RemoteServiceConfig } from "../../config";
17
17
  import { GraphQLSchemaProvider, SchemaChangeUnsubscribeHandler } from "./base";
18
18
  import { Debug } from "../../utilities";
19
19
  import { isString } from "util";
20
-
20
+ import { fetch as undiciFetch, Agent } from "undici";
21
+
22
+ const skipSSLValidationFetchOptions = {
23
+ // see https://github.com/nodejs/undici/issues/1489#issuecomment-1543856261
24
+ dispatcher: new Agent({
25
+ connect: {
26
+ rejectUnauthorized: false,
27
+ },
28
+ }),
29
+ } satisfies import("undici").RequestInit;
21
30
  export class EndpointSchemaProvider implements GraphQLSchemaProvider {
22
31
  private schema?: GraphQLSchema;
23
32
  private federatedServiceSDL?: string;
@@ -28,11 +37,11 @@ export class EndpointSchemaProvider implements GraphQLSchemaProvider {
28
37
  const { skipSSLValidation, url, headers } = this.config;
29
38
  const options: HttpOptions = {
30
39
  uri: url,
40
+ fetch: undiciFetch as typeof fetch,
31
41
  };
42
+
32
43
  if (url.startsWith("https:") && skipSSLValidation) {
33
- options.fetchOptions = {
34
- agent: new HTTPSAgent({ rejectUnauthorized: false }),
35
- };
44
+ options.fetchOptions = skipSSLValidationFetchOptions;
36
45
  }
37
46
 
38
47
  const { data, errors } = (await toPromise(
@@ -92,12 +101,10 @@ export class EndpointSchemaProvider implements GraphQLSchemaProvider {
92
101
  const { skipSSLValidation, url, headers } = this.config;
93
102
  const options: HttpOptions = {
94
103
  uri: url,
95
- fetch,
104
+ fetch: undiciFetch as typeof fetch,
96
105
  };
97
106
  if (url.startsWith("https:") && skipSSLValidation) {
98
- options.fetchOptions = {
99
- agent: new HTTPSAgent({ rejectUnauthorized: false }),
100
- };
107
+ options.fetchOptions = skipSSLValidationFetchOptions;
101
108
  }
102
109
 
103
110
  const getFederationInfoQuery = `
@@ -9,7 +9,8 @@ import {
9
9
  FileEvent,
10
10
  } from "vscode-languageserver/node";
11
11
  import { TextDocument } from "vscode-languageserver-textdocument";
12
- import type { QuickPickItem } from "vscode";
12
+ import { type QuickPickItem } from "vscode";
13
+ import { basename } from "node:path";
13
14
  import { GraphQLWorkspace } from "./workspace";
14
15
  import { LanguageServerLoadingHandler } from "./loadingHandler";
15
16
  import { debounceHandler, Debug } from "./utilities";
@@ -23,6 +24,7 @@ import { isValidationError } from "zod-validation-error";
23
24
  import { GraphQLProject } from "./project/base";
24
25
  import type { LanguageIdExtensionMap } from "../tools/utilities/languageInformation";
25
26
  import { setLanguageIdExtensionMap } from "./utilities/languageIdForExtension";
27
+ import { envFileNames, supportedConfigFileNames } from "./config";
26
28
 
27
29
  export type InitializationOptions = {
28
30
  languageIdExtensionMap: LanguageIdExtensionMap;
@@ -190,14 +192,13 @@ documents.onDidClose(
190
192
  connection.onDidChangeWatchedFiles((params) => {
191
193
  const handledByProject = new Map<GraphQLProject, FileEvent[]>();
192
194
  for (const { uri, type } of params.changes) {
195
+ const fsPath = URI.parse(uri).fsPath;
196
+ const fileName = basename(fsPath);
193
197
  if (
194
- uri.endsWith("apollo.config.js") ||
195
- uri.endsWith("apollo.config.cjs") ||
196
- uri.endsWith("apollo.config.mjs") ||
197
- uri.endsWith("apollo.config.ts") ||
198
- uri.endsWith(".env")
198
+ supportedConfigFileNames.includes(fileName) ||
199
+ envFileNames.includes(fileName)
199
200
  ) {
200
- workspace.reloadProjectForConfig(uri);
201
+ workspace.reloadProjectForConfigOrCompanionFile(uri);
201
202
  }
202
203
 
203
204
  // Don't respond to changes in files that are currently open,
@@ -125,7 +125,7 @@ export class GraphQLWorkspace {
125
125
 
126
126
  */
127
127
  const apolloConfigFiles: string[] = globSync(
128
- "**/apollo.config.@(js|ts|cjs|mjs)",
128
+ "**/apollo.config.@(js|ts|cjs|mjs|yaml|yml|json)",
129
129
  {
130
130
  cwd: URI.parse(folder.uri).fsPath,
131
131
  absolute: true,
@@ -197,7 +197,7 @@ export class GraphQLWorkspace {
197
197
  });
198
198
  }
199
199
 
200
- async reloadProjectForConfig(configUri: DocumentUri) {
200
+ async reloadProjectForConfigOrCompanionFile(configUri: DocumentUri) {
201
201
  const configPath = dirname(URI.parse(configUri).fsPath);
202
202
  let config: ApolloConfig | null;
203
203
  let error;
@@ -215,9 +215,6 @@ export class GraphQLWorkspace {
215
215
  }
216
216
  // If project exists, update the config
217
217
  if (project && config) {
218
- if (equal(project.config.rawConfig, config.rawConfig)) {
219
- return;
220
- }
221
218
  await Promise.all(project.updateConfig(config));
222
219
  this.reloadService();
223
220
  }
@@ -52,7 +52,9 @@ export function getLanguageServerClient(
52
52
  documentSelector: supportedLanguageIds,
53
53
  synchronize: {
54
54
  fileEvents: [
55
- workspace.createFileSystemWatcher("**/.env?(.local)"),
55
+ workspace.createFileSystemWatcher(
56
+ "**/{.env?(.local),apollo.config.{json,yml,yaml}}",
57
+ ),
56
58
  workspace.createFileSystemWatcher(
57
59
  "**/*{" + supportedExtensions.join(",") + "}",
58
60
  ),
@@ -601,8 +601,8 @@
601
601
  "graphql-object-field": {
602
602
  "match": "\\s*(([_A-Za-z][_0-9A-Za-z]*))\\s*(:)",
603
603
  "captures": {
604
- "1": { "name": "constant.object.key.graphql" },
605
- "2": { "name": "string.unquoted.graphql" },
604
+ "1": { "name": "string.unquoted.graphql" },
605
+ "2": { "name": "variable.object.key.graphql" },
606
606
  "3": { "name": "punctuation.graphql" }
607
607
  }
608
608
  },
@@ -1,12 +0,0 @@
1
- module.exports = {
2
- client: {
3
- service: {
4
- name: "localMultiSchema",
5
- localSchemaFile: [
6
- "./starwarsSchema.graphql",
7
- // this documents an unfixed bug: in this multi-folder-workspace, this looks for files relative to the first folder in the .code-workspace file
8
- "./planets.graphql",
9
- ],
10
- },
11
- },
12
- };
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- rover: {},
3
- };