Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DevTools <-> VSCode integration #188

Merged
merged 30 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1e30f9c
start adding devtools
phryneas Aug 28, 2024
30e5b02
first working version
phryneas Aug 29, 2024
41541e1
set `retainContextWhenHidden`
phryneas Aug 30, 2024
f32b841
testing harness
phryneas Aug 30, 2024
a76879b
show in panel instead
phryneas Sep 2, 2024
1f14d26
add CSP
phryneas Sep 2, 2024
3bf6897
`retainContextWhenHidden` not necessary anymore
phryneas Sep 2, 2024
02a27c9
panel presence configurable and "detect" mode
phryneas Sep 2, 2024
3dcc8f5
add config option for server port
phryneas Sep 2, 2024
da18007
wording
phryneas Sep 2, 2024
751f182
import devtools from package
phryneas Sep 3, 2024
7b73f64
smaller tweaks
phryneas Sep 3, 2024
09fabbd
use lifecycle in example
phryneas Sep 3, 2024
e6951e2
use vscode font size
phryneas Sep 4, 2024
88f8287
handle CSP for fetch calls to GitHub API
phryneas Sep 4, 2024
61f7bf6
comment out
phryneas Sep 4, 2024
5cdcf8d
set default to `never`, mark as experimental feature
phryneas Sep 4, 2024
6ed3511
remove vscode default styles
phryneas Sep 5, 2024
329d5d5
disable semgrep in test client
phryneas Sep 11, 2024
49712fe
use built packages
phryneas Sep 20, 2024
f314774
Merge remote-tracking branch 'origin/main' into pr/devtools-webview
phryneas Sep 20, 2024
65a25b3
Apply suggestions from code review
phryneas Sep 20, 2024
a02f5ab
lint
phryneas Sep 20, 2024
702fa50
Merge remote-tracking branch 'origin/main' into pr/devtools-webview
phryneas Dec 6, 2024
c6c9881
use package from npm
phryneas Dec 6, 2024
096869a
Adjustments to VSCode <-> DevTools communication (#197)
phryneas Dec 11, 2024
9cd5deb
reference npm package
phryneas Dec 11, 2024
16332b8
DevTools: adjustments to logging behaviour (#244)
phryneas Dec 11, 2024
7803394
changeset
phryneas Dec 11, 2024
62c7d85
Merge remote-tracking branch 'origin/main' into pr/devtools-webview
phryneas Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/stale-bears-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vscode-apollo": minor
---

Adds experimental integration of the Apollo Client DevTools
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ vscode-apollo-*.vsix
# files generated from tests
__tmp__*
.vscode-test
.yalc
yalc.lock
3 changes: 3 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ sampleWorkspace
renovate.json
images/**/*.gif
images/marketplace
.yalc
yalc.lock
start-ac.mjs
16 changes: 16 additions & 0 deletions images/apollo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 42 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 52 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
},
"dependencies": {
"@apollo/client": "3.12.2",
"@apollo/client-devtools-vscode": "^4.19.0",
"@apollo/subgraph": "2.9.1",
"@graphql-tools/schema": "10.0.6",
"@wry/equality": "0.5.7",
Expand All @@ -62,6 +63,7 @@
"vscode-languageserver-textdocument": "1.0.12",
"vscode-uri": "3.0.8",
"which": "4.0.0",
"ws": "8.18.0",
"zod": "3.23.8",
"zod-validation-error": "3.4.0"
},
Expand Down Expand Up @@ -138,6 +140,23 @@
"default": true,
"markdownDescription": "Show a \"Run in Studio\" button to the right of Operation Signatures.",
"scope": "window"
},
"apollographql.devTools.showPanel": {
"type": "string",
"enum": [
"always",
"never",
"detect"
],
"default": "never",
"markdownDescription": "[Experimental Feature] If the Apollo Client DevTools panel should be shown. If set to `detect`, the panel will only be shown if a configuration file with a client project is found in the workspace.",
"scope": "window"
},
"apollographql.devTools.serverPort": {
"type": "number",
"default": 7095,
"markdownDescription": "The Apollo Client DevTools server port. The server will be started as soon as you start using the DevTools panels.",
"scope": "window"
}
}
},
Expand Down Expand Up @@ -279,8 +298,40 @@
"command": "apollographql/showStats",
"title": "Show Status",
"category": "Apollo"
},
{
"command": "apollographql/startDevToolsServer",
"title": "Start Apollo Client DevTools Server",
"category": "Apollo",
"when": "config.apollographql.devTools.showPanel=='always' || (config.apollographql.devTools.showPanel=='detect' && vscode-apollo.hasClientProject)"
},
{
"command": "apollographql/stopDevToolsServer",
"title": "Stop Apollo Client DevTools Server",
"category": "Apollo",
"when": "config.apollographql.devTools.showPanel=='always' || (config.apollographql.devTools.showPanel=='detect' && vscode-apollo.hasClientProject)"
}
]
],
"viewsContainers": {
"panel": [
{
"id": "client-devtools",
"title": "Apollo Client DevTools",
"icon": "images/apollo.svg"
}
]
},
"views": {
"client-devtools": [
{
"type": "webview",
"id": "vscode-apollo-client-devtools",
"name": "Apollo Client DevTools",
"icon": "images/apollo.svg",
"when": "config.apollographql.devTools.showPanel=='always' || (config.apollographql.devTools.showPanel=='detect' && vscode-apollo.hasClientProject)"
}
]
}
},
"galleryBanner": {
"color": "#1d127d",
Expand Down
5 changes: 4 additions & 1 deletion sampleWorkspace/sampleWorkspace.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@
"path": "../src/language-server/__tests__/fixtures/documents"
}
],
"settings": {}
"settings": {
"apollographql.devTools.showPanel": "detect",
"apollographql.devTools.serverPort": 7095
}
}
4 changes: 4 additions & 0 deletions src/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ async function main() {
entryPoints: [
"src/extension.ts",
"src/language-server/server.ts",
{
in: require.resolve("@apollo/client-devtools-vscode/panel"),
out: "panel",
},
"src/language-server/config/config.ts",
"src/language-server/config/cache-busting-resolver.js",
],
Expand Down
39 changes: 39 additions & 0 deletions src/debug.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { OutputChannel } from "vscode";
import { TraceValues } from "vscode-languageclient";
import { format } from "node:util";

/**
* for errors (and other logs in debug mode) we want to print
Expand All @@ -21,6 +23,21 @@ export class Debug {
this.outputConsole = outputConsole;
}

private static _traceLevel: Exclude<TraceValues, "compact"> = "off";
public static get traceLevel(): TraceValues {
return Debug._traceLevel;
}
public static set traceLevel(value: TraceValues | undefined) {
console.log("setting trace level to", value);
if (value === "compact") {
// we do not handle "compact" and it's not possible to set in settings, but it doesn't hurt to at least map
// it to another value
this._traceLevel = "messages";
} else {
this._traceLevel = value || "off";
}
}

/**
* Displays an info message prefixed with [INFO]
*/
Expand Down Expand Up @@ -55,6 +72,28 @@ export class Debug {
this.outputConsole.appendLine(`[WARN] ${message}`);
}

public static traceMessage(
short: string,
verbose = short,
...verboseParams: any[]
) {
if (!this.outputConsole) return;
if (Debug.traceLevel === "verbose") {
this.outputConsole.appendLine(
`[Trace] ${format(verbose, ...verboseParams)}`,
);
} else if (Debug.traceLevel === "messages") {
this.outputConsole.appendLine(`[Trace] ${short}`);
}
}

public static traceVerbose(message: string, ...params: any[]) {
if (!this.outputConsole) return;
if (Debug.traceLevel === "verbose") {
this.outputConsole.appendLine(`[Trace] ${format(message, ...params)}`);
}
}

/**
* TODO: enable error reporting and telemetry
*/
Expand Down
Loading
Loading