vscode-apollo 1.20.0 → 2.0.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 (108) hide show
  1. package/.circleci/config.yml +27 -18
  2. package/.git-blame-ignore-revs +2 -0
  3. package/.nvmrc +1 -1
  4. package/.vscode/launch.json +9 -4
  5. package/.vscode/tasks.json +58 -16
  6. package/.vscodeignore +12 -1
  7. package/CHANGELOG.md +78 -0
  8. package/CODEOWNERS +4 -0
  9. package/README.md +97 -48
  10. package/graphql.configuration.json +5 -1
  11. package/images/marketplace/apollo-wordmark.png +0 -0
  12. package/jest.config.ts +14 -4
  13. package/jest.e2e.config.js +17 -0
  14. package/package.json +67 -68
  15. package/renovate.json +7 -0
  16. package/sampleWorkspace/clientSchema/apollo.config.cjs +10 -0
  17. package/sampleWorkspace/clientSchema/src/clientSchema.js +16 -0
  18. package/sampleWorkspace/clientSchema/src/test.js +18 -0
  19. package/sampleWorkspace/fixtures/starwarsSchema.graphql +299 -0
  20. package/sampleWorkspace/httpSchema/apollo.config.ts +8 -0
  21. package/sampleWorkspace/httpSchema/src/test.js +9 -0
  22. package/sampleWorkspace/localSchema/apollo.config.js +8 -0
  23. package/sampleWorkspace/localSchema/src/test.js +8 -0
  24. package/sampleWorkspace/localSchemaArray/apollo.config.js +12 -0
  25. package/sampleWorkspace/localSchemaArray/planets.graphql +20 -0
  26. package/sampleWorkspace/localSchemaArray/src/test.js +12 -0
  27. package/sampleWorkspace/sampleWorkspace.code-workspace +20 -0
  28. package/sampleWorkspace/spotifyGraph/apollo.config.mjs +5 -0
  29. package/sampleWorkspace/spotifyGraph/src/test.js +11 -0
  30. package/src/__e2e__/mockServer.js +117 -0
  31. package/src/__e2e__/mocks.js +13094 -0
  32. package/src/__e2e__/run.js +23 -0
  33. package/src/__e2e__/runTests.js +44 -0
  34. package/src/__e2e__/setup.js +1 -0
  35. package/src/__e2e__/vscode-environment.js +16 -0
  36. package/src/__e2e__/vscode.js +1 -0
  37. package/src/build.js +57 -0
  38. package/src/env/index.ts +0 -3
  39. package/src/extension.ts +251 -225
  40. package/src/language-server/__e2e__/clientSchema.e2e.ts +147 -0
  41. package/src/language-server/__e2e__/httpSchema.e2e.ts +21 -0
  42. package/src/language-server/__e2e__/localSchema.e2e.ts +25 -0
  43. package/src/language-server/__e2e__/localSchemaArray.e2e.ts +31 -0
  44. package/src/language-server/__e2e__/studioGraph.e2e.ts +65 -0
  45. package/src/language-server/__e2e__/utils.ts +151 -0
  46. package/src/language-server/__tests__/diagnostics.test.ts +8 -8
  47. package/src/language-server/__tests__/fileSet.test.ts +1 -1
  48. package/src/language-server/__tests__/fixtures/starwarsSchema.ts +2 -2
  49. package/src/language-server/config/__tests__/config.ts +22 -96
  50. package/src/language-server/config/__tests__/loadConfig.ts +97 -221
  51. package/src/language-server/config/__tests__/utils.ts +22 -29
  52. package/src/language-server/config/config.ts +221 -156
  53. package/src/language-server/config/loadConfig.ts +26 -153
  54. package/src/language-server/config/utils.ts +5 -16
  55. package/src/language-server/diagnostics.ts +17 -8
  56. package/src/language-server/document.ts +16 -16
  57. package/src/language-server/engine/index.ts +57 -39
  58. package/src/language-server/engine/operations/frontendUrlRoot.ts +9 -1
  59. package/src/language-server/engine/operations/schemaTagsAndFieldStats.ts +9 -1
  60. package/src/language-server/errors/__tests__/NoMissingClientDirectives.test.ts +10 -5
  61. package/src/language-server/errors/logger.ts +1 -1
  62. package/src/language-server/errors/validation.ts +20 -23
  63. package/src/language-server/fileSet.ts +10 -12
  64. package/src/language-server/format.ts +1 -1
  65. package/src/language-server/graphqlTypes.ts +13020 -3455
  66. package/src/language-server/index.ts +0 -1
  67. package/src/language-server/languageProvider.ts +29 -32
  68. package/src/language-server/loadingHandler.ts +10 -27
  69. package/src/language-server/project/base.ts +32 -25
  70. package/src/language-server/project/client.ts +80 -114
  71. package/src/language-server/project/defaultClientSchema.ts +29 -4
  72. package/src/language-server/providers/schema/__tests__/file.ts +60 -19
  73. package/src/language-server/providers/schema/base.ts +2 -2
  74. package/src/language-server/providers/schema/endpoint.ts +15 -34
  75. package/src/language-server/providers/schema/engine.ts +25 -18
  76. package/src/language-server/providers/schema/file.ts +41 -32
  77. package/src/language-server/providers/schema/index.ts +5 -21
  78. package/src/language-server/server.ts +72 -50
  79. package/src/language-server/typings/graphql.d.ts +3 -3
  80. package/src/language-server/utilities/__tests__/graphql.test.ts +42 -54
  81. package/src/language-server/utilities/debouncer.ts +1 -1
  82. package/src/language-server/utilities/debug.ts +6 -5
  83. package/src/language-server/utilities/graphql.ts +17 -16
  84. package/src/language-server/utilities/source.ts +16 -16
  85. package/src/language-server/utilities/uri.ts +2 -2
  86. package/src/language-server/workspace.ts +29 -37
  87. package/src/languageServerClient.ts +4 -4
  88. package/src/messages.ts +38 -47
  89. package/src/tools/__tests__/buildServiceDefinition.test.ts +2 -2
  90. package/src/tools/buildServiceDefinition.ts +11 -11
  91. package/src/tools/schema/resolveObject.ts +1 -1
  92. package/src/tools/utilities/predicates.ts +1 -1
  93. package/src/utils.ts +7 -6
  94. package/syntaxes/graphql.dart.json +2 -4
  95. package/syntaxes/graphql.ex.json +1 -4
  96. package/tsconfig.build.json +8 -1
  97. package/tsconfig.json +5 -3
  98. package/src/env/fetch/fetch.ts +0 -32
  99. package/src/env/fetch/global.ts +0 -30
  100. package/src/env/fetch/index.d.ts +0 -2
  101. package/src/env/fetch/index.ts +0 -2
  102. package/src/env/fetch/url.ts +0 -9
  103. package/src/env/polyfills/array.ts +0 -17
  104. package/src/env/polyfills/index.ts +0 -2
  105. package/src/env/polyfills/object.ts +0 -7
  106. package/src/language-server/engine/GraphQLDataSource.ts +0 -124
  107. package/src/language-server/project/service.ts +0 -48
  108. package/src/language-server/typings/codemirror.d.ts +0 -4
@@ -1,12 +1,12 @@
1
1
  version: 2.1
2
2
 
3
3
  orbs:
4
- secops: apollo/circleci-secops-orb@2.0.0
4
+ secops: apollo/circleci-secops-orb@2.0.7
5
5
 
6
6
  executors:
7
7
  node:
8
8
  docker:
9
- - image: circleci/node:12.16.1-browsers
9
+ - image: cimg/node:22.5.1
10
10
  working_directory: ~/vscode-graphql
11
11
 
12
12
  commands:
@@ -31,14 +31,9 @@ jobs:
31
31
  steps:
32
32
  - checkout
33
33
  - npm-install
34
- - run:
35
- name: Ensure test reports output dir exists
36
- command: mkdir -p /tmp/test-reports/lint
37
34
  - run:
38
35
  name: Run lint (currenty prettier)
39
- command: npm run lint -- --format junit --output-file /tmp/test-reports/lint/results.xml
40
- - store_test_results:
41
- path: /tmp/test-reports
36
+ command: npm run lint
42
37
 
43
38
  typescript:
44
39
  executor: node
@@ -49,28 +44,37 @@ jobs:
49
44
  name: TypeScript Check
50
45
  command: npm run typecheck
51
46
 
52
- test-unit:
47
+ test:
48
+ executor: node
49
+ steps:
50
+ - checkout
51
+ - npm-install
52
+ - run:
53
+ name: Test
54
+ command: npm run test -- --runInBand
55
+
56
+ E2E tests:
53
57
  executor: node
54
58
  steps:
55
59
  - checkout
56
60
  - npm-install
61
+ - run: sudo apt update && sudo apt install -y libasound2 libgbm1 libgtk-3-0 libnss3 xvfb
62
+ - run:
63
+ name: Build
64
+ command: npm run build:production
57
65
  - run:
58
- name: Ensure test reports output dir exists
59
- command: mkdir -p /tmp/test-reports/test-unit
66
+ command: echo 'APOLLO_KEY="service:bob-123:489fhseo4"' > ./sampleWorkspace/spotifyGraph/.env
60
67
  - run:
61
- name: Test Unit
62
- command: npm run test-unit -- --ci --reporters=jest-junit
63
- environment:
64
- JEST_JUNIT_OUTPUT_DIR: "/tmp/test-reports/test-unit"
65
- - store_test_results:
66
- path: /tmp/test-reports
68
+ name: E2E tests
69
+ command: xvfb-run -a npm run test:extension
67
70
 
68
71
  workflows:
69
72
  build-test-deploy:
70
73
  jobs:
71
74
  - lint
72
75
  - typescript
73
- - test-unit
76
+ - test
77
+ - E2E tests
74
78
  security-scans:
75
79
  jobs:
76
80
  - secops/gitleaks:
@@ -80,3 +84,8 @@ workflows:
80
84
  - secops-oidc
81
85
  git-base-revision: <<#pipeline.git.base_revision>><<pipeline.git.base_revision>><</pipeline.git.base_revision >>
82
86
  git-revision: << pipeline.git.revision >>
87
+ - secops/semgrep:
88
+ context:
89
+ - secops-oidc
90
+ - github-orb
91
+ git-base-revision: <<#pipeline.git.base_revision>><<pipeline.git.base_revision>><</pipeline.git.base_revision >>
@@ -0,0 +1,2 @@
1
+ # Run format on codebase after upgrading Prettier
2
+ d47effa7e7ad3494349d0ed5957501d1372ce59e
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- v18
1
+ v20
@@ -6,13 +6,15 @@
6
6
  "name": "Launch VS Code Extension",
7
7
  "type": "extensionHost",
8
8
  "request": "launch",
9
- "preLaunchTask": "npm: watch",
9
+ "preLaunchTask": "BuildAndStartWorkspace",
10
10
  "runtimeExecutable": "${execPath}",
11
11
  "args": [
12
- "--extensionDevelopmentPath=${workspaceRoot}"
12
+ "--extensionDevelopmentPath=${workspaceRoot}",
13
+ "--disable-extensions",
14
+ "${workspaceFolder}/sampleWorkspace/sampleWorkspace.code-workspace"
13
15
  ],
14
- "stopOnEntry": false,
15
16
  "sourceMaps": true,
17
+ "env": { "APOLLO_ENGINE_ENDPOINT": "http://localhost:7096/apollo" },
16
18
  "outFiles": ["${workspaceRoot}/lib/**/*.js"]
17
19
  },
18
20
  {
@@ -31,9 +33,12 @@
31
33
  "args": [
32
34
  "--disable-extensions",
33
35
  "--extensionDevelopmentPath=${workspaceFolder}",
36
+ "--extensionTestsPath=${workspaceFolder}/src/__e2e__/run.js",
37
+ "${workspaceFolder}/sampleWorkspace/sampleWorkspace.code-workspace"
34
38
  ],
35
39
  "outFiles": ["${workspaceFolder}/lib/**/*.js"],
36
- "preLaunchTask": "npm: watch"
40
+ "preLaunchTask": "BuildAndStartWorkspace",
41
+ "env": { "APOLLO_ENGINE_ENDPOINT": "http://localhost:7096/apollo" }
37
42
  },
38
43
  {
39
44
  "name": "Attach to Test Debugger",
@@ -1,18 +1,60 @@
1
1
  {
2
- "version": "2.0.0",
3
- "tasks": [
4
- {
5
- "type": "npm",
6
- "script": "watch",
7
- "problemMatcher": "$tsc-watch",
8
- "isBackground": true,
9
- "presentation": {
10
- "reveal": "never"
11
- },
12
- "group": {
13
- "kind": "build",
14
- "isDefault": true
15
- }
16
- }
17
- ]
2
+ "version": "2.0.0",
3
+ "tasks": [
4
+ {
5
+ "label": "npm: watch",
6
+ "type": "npm",
7
+ "script": "watch",
8
+ "problemMatcher": {
9
+ "owner": "custom",
10
+ "pattern": [
11
+ {
12
+ "regexp": "never match this please",
13
+ "file": 1,
14
+ "location": 2,
15
+ "message": 3
16
+ }
17
+ ],
18
+ "background": {
19
+ "activeOnStart": true,
20
+ "beginsPattern": "^\\s*\\[watch\\] build started.*",
21
+ "endsPattern": "^\\s*\\[watch\\] build finished.*"
22
+ }
23
+ },
24
+ "isBackground": true,
25
+ "presentation": {
26
+ "reveal": "never"
27
+ },
28
+ "group": {
29
+ "kind": "build",
30
+ "isDefault": true
31
+ }
32
+ },
33
+ {
34
+ "label": "sampleWorkspace",
35
+ "type": "npm",
36
+ "script": "sampleWorkspace:run",
37
+ "isBackground": true,
38
+ "problemMatcher": {
39
+ "owner": "custom",
40
+ "pattern": [
41
+ {
42
+ "regexp": "never match this please",
43
+ "file": 1,
44
+ "location": 2,
45
+ "message": 3
46
+ }
47
+ ],
48
+ "background": {
49
+ "activeOnStart": true,
50
+ "beginsPattern": "^\\s*Starting server.*",
51
+ "endsPattern": "^\\s*Server ready at.*"
52
+ }
53
+ }
54
+ },
55
+ {
56
+ "label": "BuildAndStartWorkspace",
57
+ "dependsOn": ["npm: watch", "sampleWorkspace"]
58
+ }
59
+ ]
18
60
  }
package/.vscodeignore CHANGED
@@ -11,7 +11,18 @@ src
11
11
  .gitattributes
12
12
  codegen.yml
13
13
  graphql.configuration.json
14
- jest.config.ts
14
+ jest.*.ts
15
+ jest.*.js
15
16
  package-lock.json
16
17
  tsconfig.build.json
17
18
  tsconfig.json
19
+ node_modules
20
+ .git*
21
+ CODEOWNERS
22
+ *.tsbuildinfo
23
+ sampleWorkspace
24
+ .changeset
25
+ .github
26
+ renovate.json
27
+ images/**/*.gif
28
+ images/marketplace
package/CHANGELOG.md CHANGED
@@ -1,5 +1,83 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#163](https://github.com/apollographql/vscode-graphql/pull/163) [`70f8895a`](https://github.com/apollographql/vscode-graphql/commit/70f8895a5f82fd6056cd47b95a0b93847bc767c6) Thanks [@phryneas](https://github.com/phryneas)! - Remove Service projects
8
+ "Service"-type projects had almost no functionality in the Extension, so they were removed
9
+
10
+ - [#169](https://github.com/apollographql/vscode-graphql/pull/169) [`ff4f0de4`](https://github.com/apollographql/vscode-graphql/commit/ff4f0de4da4d80e8bd9ea9779a8c34678b47de0d) Thanks [@phryneas](https://github.com/phryneas)! - Bundle extension instead of just building it.
11
+
12
+ - [#163](https://github.com/apollographql/vscode-graphql/pull/163) [`70f8895a`](https://github.com/apollographql/vscode-graphql/commit/70f8895a5f82fd6056cd47b95a0b93847bc767c6) Thanks [@phryneas](https://github.com/phryneas)! - Remove support for deprecated configuration environment variable `ENGINE_API_KEY`
13
+
14
+ ### Minor Changes
15
+
16
+ - [#153](https://github.com/apollographql/vscode-graphql/pull/153) [`a37cfaa6`](https://github.com/apollographql/vscode-graphql/commit/a37cfaa6bf20a8aa6ffd937e4a113ef808baf980) Thanks [@phryneas](https://github.com/phryneas)! - Add `@nonreactive` and `@defer` directives to Apollo Client schema
17
+
18
+ - [#149](https://github.com/apollographql/vscode-graphql/pull/149) [`a8fe79f6`](https://github.com/apollographql/vscode-graphql/commit/a8fe79f665f02f16e8df8d90e5134c7bc944a72e) Thanks [@phryneas](https://github.com/phryneas)! - Add support for `apollo.config.mjs`.
19
+
20
+ - [#148](https://github.com/apollographql/vscode-graphql/pull/148) [`39430fdf`](https://github.com/apollographql/vscode-graphql/commit/39430fdfd46557eff7615b3fa8e9a90ff3d6071f) Thanks [@phryneas](https://github.com/phryneas)! - Modernization:
21
+
22
+ - move from `apollo-link-*` packages to `@apollo/client` dependency
23
+ - move from `@apollo/federation` to `@apollo/subgraph`
24
+ - replace `apollo-graphql` usage with `@graphql-tools/schema`
25
+ - drop `core-js` dependency
26
+ - update internally-used `@graphql-codegen`
27
+ - update `graphql` to v16
28
+ - replace `graphql-language-service-*` packages with `graphql-language-service` package
29
+ - remove `apollo-server-errors` dependency
30
+
31
+ - [#164](https://github.com/apollographql/vscode-graphql/pull/164) [`54316f24`](https://github.com/apollographql/vscode-graphql/commit/54316f24dc598734da35d663c5a754060d40ee1c) Thanks [@phryneas](https://github.com/phryneas)! - Fix configuration error display
32
+
33
+ - [`a6e6b7c1`](https://github.com/apollographql/vscode-graphql/commit/a6e6b7c1f02bbf79291cdd0d3c79224276e2eca2) Thanks [@phryneas](https://github.com/phryneas)! - Try schema path resolution relative to configuration path.
34
+
35
+ - [#149](https://github.com/apollographql/vscode-graphql/pull/149) [`a8fe79f6`](https://github.com/apollographql/vscode-graphql/commit/a8fe79f665f02f16e8df8d90e5134c7bc944a72e) Thanks [@phryneas](https://github.com/phryneas)! - Modernization:
36
+
37
+ - update `cosmiconfig`
38
+ - drop now-obsolete `@endemolshinegroup/cosmiconfig-typescript-loader`
39
+
40
+ - [#163](https://github.com/apollographql/vscode-graphql/pull/163) [`70f8895a`](https://github.com/apollographql/vscode-graphql/commit/70f8895a5f82fd6056cd47b95a0b93847bc767c6) Thanks [@phryneas](https://github.com/phryneas)! - Configuration parsing has been reworked based on `zod`.
41
+
42
+ - [#153](https://github.com/apollographql/vscode-graphql/pull/153) [`a37cfaa6`](https://github.com/apollographql/vscode-graphql/commit/a37cfaa6bf20a8aa6ffd937e4a113ef808baf980) Thanks [@phryneas](https://github.com/phryneas)! - Remove unused `clientOnlyDirectives`, `clientSchemaDirectives` and `addTypename` client project config options.
43
+
44
+ - [#146](https://github.com/apollographql/vscode-graphql/pull/146) [`0721afe9`](https://github.com/apollographql/vscode-graphql/commit/0721afe9108a7b8b540fd18e967b9b138aee58f5) Thanks [@phryneas](https://github.com/phryneas)! - Modernization:
45
+
46
+ - set minimum VSCode version to 1.90.0
47
+ - update build target to ES2020
48
+ - drop `node-fetch` and similar polyfills
49
+ - update `vscode-languageclient/-server` modules
50
+ - migrate from the deprecated `vscode` module to `@types/vscode`
51
+ - update `typescript` developement dependency to 5.5
52
+
53
+ - [#163](https://github.com/apollographql/vscode-graphql/pull/163) [`70f8895a`](https://github.com/apollographql/vscode-graphql/commit/70f8895a5f82fd6056cd47b95a0b93847bc767c6) Thanks [@phryneas](https://github.com/phryneas)! - Remove support for unused configuration options
54
+ The configuration options `client.name`, `client.referenceId`, `client.version`, `client.statsWindow`, `client.clientOnlyDirectives`, and `client.clientSchemaDirectives` had no effect in the extension, so they have been removed.
55
+
56
+ ### Patch Changes
57
+
58
+ - [#150](https://github.com/apollographql/vscode-graphql/pull/150) [`eeed0b8e`](https://github.com/apollographql/vscode-graphql/commit/eeed0b8e2bbb109c5796b3cda5516c5a6817059a) Thanks [@phryneas](https://github.com/phryneas)! - Modernization
59
+
60
+ - update `glob`
61
+ - add E2E tests
62
+
63
+ - [#149](https://github.com/apollographql/vscode-graphql/pull/149) [`a8fe79f6`](https://github.com/apollographql/vscode-graphql/commit/a8fe79f665f02f16e8df8d90e5134c7bc944a72e) Thanks [@phryneas](https://github.com/phryneas)! - Fixed a bug where changes in `apollo.config.ts` or `apollo.config.cjs` would require a manual extension reload.
64
+
65
+ - [#160](https://github.com/apollographql/vscode-graphql/pull/160) [`5312c6e8`](https://github.com/apollographql/vscode-graphql/commit/5312c6e8cd1cddb0ad762843c30e62caf5169f1d) Thanks [@phryneas](https://github.com/phryneas)! - Replace `graphql-datasource` usage with `@apollo/client`
66
+
67
+ - [#161](https://github.com/apollographql/vscode-graphql/pull/161) [`7fd57310`](https://github.com/apollographql/vscode-graphql/commit/7fd57310e5483584068550b762d91491379b90a5) Thanks [@phryneas](https://github.com/phryneas)! - Only show "Run in Studio" gutter action for local graphs if an endpoint is configured.
68
+
69
+ - [#159](https://github.com/apollographql/vscode-graphql/pull/159) [`952ef37d`](https://github.com/apollographql/vscode-graphql/commit/952ef37df0cf035a1af46918ef1f38868a7aa282) Thanks [@phryneas](https://github.com/phryneas)! - Fix a bug where unrelated project configurations could be merged into each other.
70
+
71
+ - [#161](https://github.com/apollographql/vscode-graphql/pull/161) [`7fd57310`](https://github.com/apollographql/vscode-graphql/commit/7fd57310e5483584068550b762d91491379b90a5) Thanks [@phryneas](https://github.com/phryneas)! - Modernization
72
+
73
+ - update `minimatch` and `lz-string`
74
+ - drop `await-to-js`, `resolve-from`, `sha.js`
75
+ - drop `query-string`
76
+
77
+ - [#161](https://github.com/apollographql/vscode-graphql/pull/161) [`7fd57310`](https://github.com/apollographql/vscode-graphql/commit/7fd57310e5483584068550b762d91491379b90a5) Thanks [@phryneas](https://github.com/phryneas)! - Fix a bug where the "Run in Studio" button would link to a Studio Graph instead of Explorer for local projects.
78
+
79
+ - [#160](https://github.com/apollographql/vscode-graphql/pull/160) [`5312c6e8`](https://github.com/apollographql/vscode-graphql/commit/5312c6e8cd1cddb0ad762843c30e62caf5169f1d) Thanks [@phryneas](https://github.com/phryneas)! - Prevent accidental creation of multiple output channels
80
+
3
81
  ## 1.20.0
4
82
 
5
83
  ### Minor Changes
package/CODEOWNERS ADDED
@@ -0,0 +1,4 @@
1
+ # This file was automatically generated by the Apollo SecOps team
2
+ # Please customize this file as needed prior to merging.
3
+
4
+ * @apollographql/client-typescript
package/README.md CHANGED
@@ -1,4 +1,13 @@
1
- # Apollo GraphQL for VS Code
1
+ <div align="center">
2
+
3
+ <p>
4
+ <a href="https://www.apollographql.com/"><img src="https://raw.githubusercontent.com/apollographql/vscode-graphql/main/images/marketplace/apollo-wordmark.png" height="100" alt=""></a>
5
+ </p>
6
+ <h1>Apollo GraphQL for VS Code</h1>
7
+
8
+ [![Visual Studio Marketplace Version (including pre-releases)](https://img.shields.io/visual-studio-marketplace/v/apollographql.vscode-apollo)](https://marketplace.visualstudio.com/items?itemName=apollographql.vscode-apollo) [![Visual Studio Marketplace Installs](https://img.shields.io/visual-studio-marketplace/i/apollographql.vscode-apollo)](https://marketplace.visualstudio.com/items?itemName=apollographql.vscode-apollo) [![Build Status](https://circleci.com/gh/apollographql/vscode-graphql.svg?style=svg)](https://circleci.com/gh/apollographql/vscode-graphql) [![Join the community](https://img.shields.io/discourse/status?label=Join%20the%20community&server=https%3A%2F%2Fcommunity.apollographql.com)](https://community.apollographql.com) [![Join our Discord server](https://img.shields.io/discord/1022972389463687228.svg?color=7389D8&labelColor=6A7EC2&logo=discord&logoColor=ffffff&style=flat-square)](https://discord.gg/graphos)
9
+
10
+ </div>
2
11
 
3
12
  GraphQL has the potential to create incredible developer experiences, thanks to its strongly typed schema and query language. The Apollo platform brings these possibilities to life by enhancing your editor with rich metadata from your graph API.
4
13
 
@@ -6,52 +15,54 @@ GraphQL has the potential to create incredible developer experiences, thanks to
6
15
 
7
16
  The Apollo GraphQL extension for VS Code brings an all-in-one tooling experience for developing apps with Apollo.
8
17
 
9
- - Add [syntax highlighting](#syntax) for GraphQL files and gql templates inside JavaScript files
10
- - Get instant feedback and [intelligent autocomplete](#autocomplete) for fields, arguments, types, and variables as you write queries
11
- - Seamlessly manage your client-side schema alongside your remote one
12
- - [See performance information](#performance-insights) inline with your query definitions
18
+ - Add [syntax highlighting](#syntax-highlighting) for GraphQL files and gql templates inside JavaScript files
19
+ - Get instant feedback and [intelligent autocomplete](#intelligent-autocomplete) for fields, arguments, types, and variables as you write queries
20
+ - Manage client side schema alongside remote schema
21
+ - See [performance information](#performance-insights) inline with your query definitions
13
22
  - Validate field and argument usage in operations
14
- - [Navigate projects](#navigating-projects) easier with jump-to and peek-at definitions and more
23
+ - [Navigate projects more easily](#navigating-projects) with jump-to and peek-at definitions
15
24
  - Manage [client-only](#client-only-schemas) schemas
16
- - [Switch schema tags](#commands) to work on upcoming features
25
+ - [Switch graph variants](#graph-variant-switching) to work with schemas running on different environments
17
26
 
18
27
  <h2 id="getting-started">Getting started</h2>
19
28
 
20
- Some features of this extension (like syntax highlighting) will work without any configuration, but to get all of the benefits of the VS Code experience, it's best to link the schema that is being developed against **before** installing the extension. The best way to do that is by [publishing a schema](https://www.apollographql.com/docs/graphos/delivery/) to the Apollo schema registry. Once that is done, two steps are needed:
29
+ To get all the benefits of the VS Code experience, it's best to link the schema that is being developed against before installing the extension. The best way to do that is by [publishing a schema](https://www.apollographql.com/docs/graphos/delivery/publishing-schemas/) to the Apollo schema registry. After that's done:
21
30
 
22
- 1. Create an `apollo.config.js` at the root of the project
23
- 2. Copy an API key from the Apollo Studio dashboard of the published graph
31
+ 1. Create an `apollo.config.js` file at the root of the project.
32
+ Alternatively, you can create a `cjs`, `mjs`, or `ts` file with the same configuration.
33
+ 2. Obtain a [Personal API key](https://www.apollographql.com/docs/graphos/api-keys) from GraphOS Studio.
24
34
 
25
35
  <h3 id="apollo-config">Setting up an Apollo config</h3>
26
36
 
27
- In order for the VS Code plugin to know how to find the schema, it needs to be linked to either a published schema or a local one. To link a project to a published schema, edit the `apollo.config.js` file to look like this:
37
+ For the VS Code plugin to know how to find the schema, it needs to be linked to either a published schema or a local one. To link a project to a published schema, edit the `apollo.config.js` file to look like this:
28
38
 
29
39
  ```js
30
40
  module.exports = {
31
41
  client: {
32
- service: "my-graphql-app"
33
- }
42
+ service: "my-graphql-app",
43
+ },
34
44
  };
35
45
  ```
36
46
 
37
- The service name is the id of the graph created in Apollo and can be found in the graphs dashboard of [Apollo Studio](https://studio.apollographql.com)
47
+ The `service` name is the name of the graph you've created in [GraphOS Studio](https://studio.apollographql.com).
38
48
 
39
- > Important note: If the display name of the graph in Studio is changed, this value should still remain the same graph **ID**. This can be found in the url when browsing the graph in Studio.
49
+ See [additional configuration options](#additional-apollo-config-options).
40
50
 
41
- <h3 id="api-key">Setting up an API key</h3>
42
- To authenticate with Apollo to pull down the schema, create a file next to the `apollo.config.js` called `.env`. This should be an untracked file (i.e. don't push it to GitHub). Go to the settings page of the published service and create a new API key.
51
+ <h3 id="api-key">Setting up the <code>.env</code> file</h3>
43
52
 
44
- > It is best practice to create a new API key for each member of the team and name the key so it's easy to find and revoke if needed
53
+ To authenticate with GraphOS Studio to pull down your schema, create a `.env` file in the same directory as the `apollo.config.js` file. This should be an untracked file (that is, don't commit it to Git).
45
54
 
46
- > If you're working on a project that traces the `.env` file, you can optionally create an untrace `.env.local` file to store your API key
55
+ Then go to your [User Settings page](https://studio.apollographql.com/user-settings/api-keys?referrer=docs-content) in GraphOS Studio to create a new Personal API key.
47
56
 
48
- After the key is found, add the following line to the `.env` or `.env.local` file:
57
+ > It is best practice to create a new API key for each member of the team and name the key so its easy to find and revoke if needed. This will be easier to manage in the future.
49
58
 
50
- ```bash
59
+ After the key is found, add the following line to the `.env` file:
60
+
61
+ ```bash showLineNumbers=false
51
62
  APOLLO_KEY=<enter copied key here>
52
63
  ```
53
64
 
54
- After this is done, VS Code should automatically update and start providing autocomplete, validation, and more!
65
+ After this is done, VS Code can be reloaded and the Apollo integration will connect to GraphOS Studio to provide autocomplete, validation, and more.
55
66
 
56
67
  <h3 id="local-schemas">Local schemas</h3>
57
68
 
@@ -62,35 +73,52 @@ module.exports = {
62
73
  client: {
63
74
  service: {
64
75
  name: "my-graphql-app",
65
- url: "http://localhost:4000/graphql"
66
- }
67
- }
76
+ url: "http://localhost:4000/graphql",
77
+ },
78
+ },
68
79
  };
69
80
  ```
70
81
 
71
- > Linking to the local schema won't provide all features such as switching schema tags and performance metrics.
82
+ Linking to the local schema won't provide all features, such as switching graph variants and performance metrics.
72
83
 
73
- More information about configuring an Apollo project can be found [here](https://www.apollographql.com/docs/references/apollo-config.html)
84
+ <h3 id="local-schema-files">Local schema files</h3>
85
+
86
+ You might not always have a running server to link to, so the extension also supports linking to a local schema file.
87
+ This is useful for working on a schema in isolation or for testing out new features.
88
+ To link to a local schema file, add the following to the `apollo.config.js` file:
89
+
90
+ ```js
91
+ module.exports = {
92
+ client: {
93
+ service: {
94
+ // can be a string pointing to a single file or an array of strings
95
+ localSchemaFile: "./path/to/schema.graphql",
96
+ },
97
+ },
98
+ };
99
+ ```
74
100
 
75
101
  <h3 id="client-only-schemas">Client-only schemas</h3>
76
102
 
77
- One of the best features of the VS Code extension is the automatic merging of remote schemas and local ones when using integrated state management with Apollo Client. This happens automatically whenever schema definitions are found within a client project. By default, the VS Code extension will look for all files under `./src` to find both the operations and schema definitions for building a complete schema for the application.
103
+ One of the best features of the VS Code extension is the automatic merging of remote schemas and local ones when using integrated state management with Apollo Client. This happens automatically whenever schema definitions are found within a client project. By default, the VS Code extension will look for all JavaScript, TypeScript and GraphQL files under `./src` to find both the operations and schema definitions for building a complete schema for the application.
78
104
 
79
- Client-side schema definitions can be spread throughout the client app project and will be merged together to create one single schema. If the default behavior isn't ideal, this can be controlled through the `apollo.config.js` at the root of the project:
105
+ Client side schema definitions can be spread throughout the client app project and will be merged together to create one single schema. The default behavior can be controlled by adding specifications to the `apollo.config.js`:
80
106
 
81
107
  ```js
82
108
  module.exports = {
83
109
  client: {
84
- service: "my-graphql-app"
110
+ service: "my-graphql-app",
111
+ // array of glob patterns
85
112
  includes: ["./src/**/*.js"],
86
- excludes: ["**/__tests__/**"]
87
- }
88
- }
113
+ // array of glob patterns
114
+ excludes: ["**/__tests__/**"],
115
+ },
116
+ };
89
117
  ```
90
118
 
91
119
  <h3 id="get-the-extension">Get the extension</h3>
92
120
 
93
- Once you have a config set up and a schema published, **install the Apollo GraphQL extension** by using this [link](https://marketplace.visualstudio.com/items?itemName=apollographql.vscode-apollo) or by searching `Apollo` in the VS Code extension marketplace. After installation, try opening a file containing a GraphQL operation.
121
+ Once you have a config set up and a schema published, [install the Apollo GraphQL extension](https://marketplace.visualstudio.com/items?itemName=apollographql.vscode-apollo), then try opening a file containing a GraphQL operation.
94
122
 
95
123
  When a file open, clicking the status bar icon will open the output window and print stats about the project associated with that file. This is helpful when confirming the project is setup properly.
96
124
 
@@ -100,7 +128,7 @@ When a file open, clicking the status bar icon will open the output window and p
100
128
 
101
129
  Apollo for VS Code brings many helpful features for working on a GraphQL project.
102
130
 
103
- <h3 id="autocomplete">Intelligent autocomplete</h3>
131
+ <h3 id="intelligent-autocomplete">Intelligent autocomplete</h3>
104
132
 
105
133
  Once configured, VS Code has full knowledge of the schema clients are running operations against, including client-only schemas (for things like local state mutations). Because of this, it have the ability to autocomplete fields and arguments as you type.
106
134
 
@@ -122,35 +150,56 @@ Because of GraphQL's strongly-typed schema, VS Code not only know about which fi
122
150
 
123
151
  GraphQL's flexibility can make it difficult to predict the cost of an operation. Without insight into how expensive an operation is, developers can accidentally write queries that place strain on their graph API's underlying backends. Thanks to the Apollo platform's integration with VS Code and our trace warehouse, teams can avoid these performance issues altogether by instantly seeing the cost of a query right in their editor.
124
152
 
125
- To turn on tracing for your GraphQL server, please visit our [guide](https://www.apollographql.com/docs/platform/setup-analytics.html).
126
-
127
- The VS Code extension will show inline performance diagnostics when connected to a service with reported metrics in Apollo Studio. As operations are typed, any fields that take longer than 1ms to respond will be annotated to the right of the field inline! This gives team members a picture of how long the operation will take as more and more fields are added to operations or fragments.
153
+ The VS Code extension will show inline performance diagnostics when connected to a service with reported metrics in GraphOS Studio. As operations are typed, any fields that take longer than 1 ms to respond will be annotated to the right of the field inline! This gives team members a picture of how long the operation will take as more and more fields are added to operations or fragments.
128
154
 
129
- <img src="https://raw.githubusercontent.com/apollographql/vscode-graphql/main/images/marketplace/perf-annotation.png" style="max-width:800px;" alt="Performance annotation next to a field">
155
+ <img
156
+ src="https://raw.githubusercontent.com/apollographql/vscode-graphql/80a6ca4ae59173b8cef25020345e4ebe202eec41/images/marketplace/perf-annotation.png"
157
+ width="80%"
158
+ style="margin: 5%"
159
+ alt="Performance annotation next to a field"
160
+ />
130
161
 
131
- <h3 id="syntax">Syntax highlighting</h3>
162
+ <h3 id="syntax-highlighting">Syntax highlighting</h3>
132
163
 
133
- Apollo's editor extension provides syntax highlighting for all things GraphQL, including schema definitions in `.graphql` files, complex queries in TypeScript, and even client-only schema extensions. Syntax highlighting for GraphQL works out-of-the-box for `.graphql`, `.gql`, `.js` and `.ts` file types!
164
+ Apollo's editor extension provides syntax highlighting for all things GraphQL, including schema definitions in `.graphql` files, complex queries in TypeScript, and even client-only schema extensions. Syntax highlighting for GraphQL works out-of-the-box for `.graphql`, `.gql`, `.js` and `.ts` file types.
134
165
 
135
166
  <h3 id="navigating-projects">Navigating projects</h3>
136
167
 
137
- Navigating large codebases can be difficult, but the Apollo GraphQL extension makes this easier than ever. Right-clicking on any field in operations or schemas gives you the ability to jump to (or peek at) definitions, as well as find any other references to that field in your project. Searching a project for any occurrence of a certain field is now a thing of the past!
168
+ Navigating large codebases can be difficult, but the Apollo GraphQL extension makes this easier. Right-clicking on any field in operations or schemas gives you the ability to jump to (or peek at) definitions, as well as find any other references to that field in your project.
138
169
 
139
170
  <img src="https://raw.githubusercontent.com/apollographql/vscode-graphql/main/images/marketplace/jump-to-def.gif" alt="Using jump to definition on a fragment">
140
171
 
141
- <h3 id="commands">Schema tag switching</h3>
172
+ <h3 id="graph-variant-switching">Schema tag switching</h3>
142
173
 
143
- The Apollo GraphQL platform supports publishing multiple versions (tags) of a schema. This is useful for developing on a future development schema and preparing your clients to conform to that schema. To choose another schema tag, open the Command Palette (`cmd + shift + p` on mac), search "Apollo" and choose the "Apollo: Select Schema Tag" option.
174
+ Apollo supports publishing multiple versions ([variants](https://www.apollographql.com/docs/graphos/graphs/#variants)) of a schema. This is useful for developing on a future development schema and preparing your clients to conform to that schema. To switch between graph variants, open the Command Palette (`cmd + shift + p` on mac), search "Apollo" and choose the "Apollo: Select Schema Tag" option.
144
175
 
145
176
  <h2 id="troubleshooting">Troubleshooting</h2>
146
177
 
147
- The most common errors are configuration errors, like a missing `.env` file, missing `.env.local` file, or incorrect service information in the `apollo.config.js` file.
148
- There is more information about configuring an Apollo projects [here](https://www.apollographql.com/docs/references/apollo-config.html).
178
+ The most common errors are configuration errors, like a missing `.env` file or incorrect service information in the `apollo.config.js` file. Please see [the Apollo config docs](https://www.apollographql.com/docs/devtools/apollo-config/) for more configuration guidance.
149
179
 
150
180
  Other errors may be caused from an old version of a published schema. To reload a schema, open the Command Palette (`cmd + shift + p` on mac), search "Apollo" and choose the "Apollo: Reload Schema" option.
151
181
 
152
- Sometimes errors will show up as a notification at the bottom of your editor. Other, less critical messages may be shown in the output pane of the editor. To open the output pane and get diagnostic information about the extension and the current service loaded (if working with a client project), just click the "Apollo GraphQL" icon in the status bar at the bottom.
182
+ Sometimes errors will show up as a notification at the bottom of your editor. Other, less critical, messages may be shown in the output pane of the editor. To open the output pane and get diagnostic information about the extension and the current service loaded (if working with a client project), just click the "Apollo GraphQL" icon in the status bar at the bottom.
153
183
 
154
184
  <img src="https://raw.githubusercontent.com/apollographql/vscode-graphql/main/images/marketplace/stats.gif" alt="Clicking the status bar icon to open the output pane">
155
185
 
156
- If problems persist or the error messages are unhelpful, an [issue](https://github.com/apollographql/apollo-tooling/issues) can be opened on the `apollo-tooling` repository.
186
+ If problems persist or the error messages are unhelpful, open an [issue](https://github.com/apollographql/vscode-graphql/issues) in the `vscode-graphql` repository.
187
+
188
+ <h2 id="additional-apollo-config-options">Additional Apollo config options</h2>
189
+
190
+ You can add these configurations to your [Apollo config file](#setting-up-an-apollo-config).
191
+
192
+ <h3 id="option-client-tagName">client.tagName</h3>
193
+
194
+ _Optional_ - custom tagged template literal.
195
+
196
+ When using GraphQL with JavaScript or TypeScript projects, it is common to use the `gql` tagged template literal to write out operations. Apollo tools look through your files for the `gql` tag to extract your queries, so if you use a different template literal, you can configure it like so:
197
+
198
+ ```js
199
+ module.exports = {
200
+ client: {
201
+ tagName: "graphql", // highlight-line
202
+ service: ...
203
+ }
204
+ };
205
+ ```
@@ -2,5 +2,9 @@
2
2
  "comments": {
3
3
  "lineComment": "#"
4
4
  },
5
- "brackets": [["{", "}"], ["[", "]"], ["(", ")"]]
5
+ "brackets": [
6
+ ["{", "}"],
7
+ ["[", "]"],
8
+ ["(", ")"]
9
+ ]
6
10
  }
package/jest.config.ts CHANGED
@@ -1,11 +1,21 @@
1
- import type { Config } from '@jest/types';
1
+ import type { Config } from "@jest/types";
2
2
 
3
3
  const config: Config.InitialOptions = {
4
- roots: ['<rootDir>/src'],
5
- testMatch: ['**/__tests__/**/*.test.ts'],
4
+ roots: ["<rootDir>/src"],
5
+ snapshotFormat: {
6
+ escapeString: true,
7
+ printBasicPrototype: true,
8
+ },
9
+ testMatch: ["**/__tests__/**/*.ts"],
10
+ testPathIgnorePatterns: [
11
+ "/node_modules/",
12
+ "/fixtures/",
13
+ "/snapshotSerializers/",
14
+ ],
6
15
  transform: {
7
- '^.+\\.(ts)$': 'ts-jest',
16
+ "^.+\\.(ts)$": "ts-jest",
8
17
  },
18
+ prettierPath: null,
9
19
  };
10
20
 
11
21
  export default config;
@@ -0,0 +1,17 @@
1
+ // see https://github.com/microsoft/vscode-test/issues/37#issuecomment-700167820
2
+ const path = require("path");
3
+
4
+ module.exports = {
5
+ moduleFileExtensions: ["js", "ts"],
6
+ testMatch: ["<rootDir>/src/**/*.e2e.ts"],
7
+ testEnvironment: "./src/__e2e__/vscode-environment.js",
8
+ setupFiles: ["./src/__e2e__/setup.js"],
9
+ verbose: true,
10
+ moduleNameMapper: {
11
+ vscode: path.join(__dirname, "src", "__e2e__", "vscode.js"),
12
+ },
13
+ transform: {
14
+ "^.+\\.(ts)$": "ts-jest",
15
+ },
16
+ prettierPath: null,
17
+ };