Skip to content

Commit 5996243

Browse files
authored
graphql-language-service-cli: init at 3.5.0 (#384397)
2 parents beb9ac1 + d872a2a commit 5996243

File tree

4 files changed

+162
-0
lines changed

4 files changed

+162
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
lib,
3+
fetchFromGitHub,
4+
fetchYarnDeps,
5+
makeWrapper,
6+
nodejs,
7+
stdenv,
8+
yarnBuildHook,
9+
yarnConfigHook,
10+
versionCheckHook,
11+
}:
12+
13+
stdenv.mkDerivation (finalAttrs: {
14+
pname = "graphql-language-service-cli";
15+
version = "3.5.0";
16+
17+
src = fetchFromGitHub {
18+
owner = "graphql";
19+
repo = "graphiql";
20+
tag = "graphql-language-service-cli@${finalAttrs.version}";
21+
hash = "sha256-NJTggaMNMjOP5oN+gHxFTwEdNipPNzTFfA6f975HDgM=";
22+
};
23+
24+
patches = [
25+
./patches/0001-repurpose-vscode-graphql-build-script.patch
26+
];
27+
28+
yarnOfflineCache = fetchYarnDeps {
29+
yarnLock = "${finalAttrs.src}/yarn.lock";
30+
hash = "sha256-ae6KP2sFgw8/8YaTJSPscBlVQ5/bzbvHRZygcMgFAlU=";
31+
};
32+
33+
nativeBuildInputs = [
34+
yarnConfigHook
35+
yarnBuildHook
36+
nodejs
37+
makeWrapper
38+
];
39+
40+
installPhase = ''
41+
runHook preInstall
42+
43+
mkdir -p $out/{bin,lib}
44+
45+
pushd packages/graphql-language-service-cli
46+
47+
node esbuild.js --minify
48+
49+
# copy package.json for --version command
50+
mv {out/graphql.js,package.json} $out/lib
51+
52+
makeWrapper ${lib.getExe nodejs} $out/bin/graphql-lsp \
53+
--add-flags $out/lib/graphql.js \
54+
55+
popd
56+
57+
runHook postInstall
58+
'';
59+
60+
nativeInstallCheckInputs = [ versionCheckHook ];
61+
doInstallCheck = true;
62+
versionCheckProgram = "${placeholder "out"}/bin/${finalAttrs.meta.mainProgram}";
63+
64+
passthru = {
65+
updateScript = ./updater.sh;
66+
};
67+
68+
meta = {
69+
description = "Official, runtime independent Language Service for GraphQL";
70+
homepage = "https://github.com/graphql/graphiql";
71+
changelog = "https://github.com/graphql/graphiql/blob/${finalAttrs.src.tag}/packages/graphql-language-service-cli/CHANGELOG.md";
72+
license = lib.licenses.mit;
73+
maintainers = with lib.maintainers; [ nathanregner ];
74+
mainProgram = "graphql-lsp";
75+
};
76+
})
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
From ceeca9463380ab11483ec22f9e46fdc3f83162b0 Mon Sep 17 00:00:00 2001
2+
From: Nathan Regner <[email protected]>
3+
Date: Sat, 15 Mar 2025 15:50:13 -0600
4+
Subject: [PATCH] Repurpose vscode-graphql build script
5+
6+
Bundling the output script means we don't have to ship 1GB of
7+
`node_modules` (there are lots of unrelated dependencies used by other
8+
packages in the monorepo).
9+
---
10+
.../esbuild.js | 28 ++-----------------
11+
1 file changed, 2 insertions(+), 26 deletions(-)
12+
rename packages/{vscode-graphql => graphql-language-service-cli}/esbuild.js (59%)
13+
14+
diff --git a/packages/vscode-graphql/esbuild.js b/packages/graphql-language-service-cli/esbuild.js
15+
similarity index 59%
16+
rename from packages/vscode-graphql/esbuild.js
17+
rename to packages/graphql-language-service-cli/esbuild.js
18+
index 744f4e60..4b9147fa 100644
19+
--- a/packages/vscode-graphql/esbuild.js
20+
+++ b/packages/graphql-language-service-cli/esbuild.js
21+
@@ -1,12 +1,8 @@
22+
const { build } = require('esbuild');
23+
const [, , arg] = process.argv;
24+
25+
-const logger = console;
26+
-
27+
-const isWatchMode = arg === '--watch';
28+
-
29+
build({
30+
- entryPoints: ['src/extension.ts', 'src/server/index.ts'],
31+
+ entryPoints: ['bin/graphql.js'],
32+
bundle: true,
33+
minify: arg === '--minify',
34+
platform: 'node',
35+
@@ -50,24 +46,4 @@ build({
36+
'liquor',
37+
'twig',
38+
],
39+
-})
40+
- .then(({ errors, warnings }) => {
41+
- if (warnings.length) {
42+
- logger.warn(...warnings);
43+
- }
44+
- if (errors.length) {
45+
- logger.error(...errors);
46+
- }
47+
-
48+
- logger.log('successfully bundled vscode-graphql 🚀');
49+
-
50+
- if (isWatchMode) {
51+
- logger.log('watching... 🕰');
52+
- } else {
53+
- process.exit();
54+
- }
55+
- })
56+
- .catch(err => {
57+
- logger.error(err);
58+
- process.exit(1);
59+
- });
60+
+});
61+
--
62+
2.48.1
63+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env nix-shell
2+
#!nix-shell -i bash -p coreutils curl jq nix-update
3+
4+
set -euo pipefail
5+
6+
# this package is part of a monorepo with many tags; nix-update only seems to
7+
# fetch the 10 most recent
8+
# https://github.com/Mic92/nix-update/issues/231
9+
owner="graphql"
10+
repo="graphiql"
11+
version=$(
12+
curl -s ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} "https://api.github.com/repos/graphql/graphiql/git/refs/tags/graphql-language-service-cli" |
13+
jq 'map(.ref | capture("refs/tags/graphql-language-service-cli@(?<version>[0-9.]+)").version) | .[]' -r |
14+
sort --reverse --version-sort | head -n1
15+
)
16+
17+
if [[ "$UPDATE_NIX_OLD_VERSION" == "$version" ]]; then
18+
echo "Already up to date!"
19+
exit 0
20+
fi
21+
22+
nix-update graphql-language-service-cli --version $version

pkgs/development/node-packages/aliases.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ mapAliases {
117117
inherit (pkgs) gramma; # added 2024-06-26
118118
grammarly-languageserver = throw "grammarly-languageserver was removed because it requires EOL Node.js 16"; # added 2024-07-15
119119
inherit (pkgs) graphite-cli; # added 2024-01-25
120+
inherit (pkgs) graphql-language-service-cli; # added 2025-03-17
120121
inherit (pkgs) graphqurl; # added 2023-08-19
121122
gtop = pkgs.gtop; # added 2023-07-31
122123
hs-client = pkgs.hsd; # added 2023-08-20

0 commit comments

Comments
 (0)