Skip to content

Commit

Permalink
release vscode-graphql@0.4.2 from the monorepo (#2288)
Browse files Browse the repository at this point in the history
- fix esbuild bundling issues with vscode-graphql [#2269](#2269) by fixing esbuild version
- remove `graphql-language-service` dependency on `graphql-config`, which is only for types
- remove direct `vscode-graphql` dependency on `graphql-config`, which previously existed for op exec client
- resolve `graphql-config` to `4.3.0` in `graphql-language-server`
  • Loading branch information
acao committed Apr 11, 2022
1 parent 2c26eea commit c36504a
Show file tree
Hide file tree
Showing 17 changed files with 408 additions and 251 deletions.
8 changes: 8 additions & 0 deletions .changeset/old-mugs-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'graphql-language-service': patch
'graphql-language-service-server': patch
'vscode-graphql': patch
---
- upgrade `graphql-config` to latest in server
- remove `graphql-config` dependency from `vscode-graphql` and `graphql-language-service`
- fix `vscode-graphql` esbuild bundling bug in `vscode-graphql` [#2269](https://github.com/graphql/graphiql/issues/2269) by fixing `esbuild` version
5 changes: 3 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"tasks": [
{
"label": "watch-vscode",
"type": "shell",
"command": "source ~/.zshrc; yarn run watch-vscode",
"type": "npm",
"script": "watch-vscode",
"problemMatcher": ["$tsc-watch"],
"isBackground": true,
"presentation": {
"reveal": "always"
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@
"build:clean": "yarn tsc --clean",
"build:watch": "yarn tsc --watch",
"watch": "yarn build:watch",
"watch-vscode:prebuild": "yarn build && yarn workspace vscode-graphql run build-bundles",
"watch-vscode:bundle": "chokidar 'packages/*/dist/**/*.{js,ts}' -c 'yarn workspace vscode-graphql run build-bundles'",
"watch-vscode": "yarn watch-vscode:prebuild && concurrently 'yarn tsc --watch' 'yarn watch-vscode:bundle'",
"watch-vscode": "concurrently --raw 'yarn tsc --watch' 'yarn workspace vscode-graphql run compile --watch'",
"check": "yarn tsc --dry",
"cypress-open": "yarn workspace graphiql cypress-open",
"dev-graphiql": "yarn workspace graphiql dev",
Expand All @@ -59,7 +57,7 @@
"prepublishOnly": "./scripts/prepublish.sh",
"pretty": "node scripts/pretty.js",
"pretty-check": "node scripts/pretty.js --check",
"release": "yarn build && yarn build-bundles && yarn changeset publish && wsrun release",
"release": "yarn build && yarn build-bundles && yarn changeset publish",
"release:canary": "(node scripts/canary-release.js && yarn build && yarn build-bundles && yarn changeset publish --tag canary) || echo Skipping Canary...",
"repo:lint": "manypkg check",
"repo:fix": "manypkg fix",
Expand Down
30 changes: 27 additions & 3 deletions packages/graphql-language-service-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,39 @@ The custom graphql language configurations are:
- `customDirectives` - `['@myExampleDirective']`
- `customValidationRules` - returns rules array with parameter `ValidationContext` from `graphql/validation`

### LSP Workspace Configuration

When running `server`, your LSP-compatible client can [provide additional workspace configuration](https://npmjs.com/graphql-language-service-server#workspace-configuration).

For example, `coc.nvim` allows for providing custom `settings`

```json
"languageserver": {
"graphql": {
"command": "graphql-lsp",
"args": ["server", "-m", "stream"],
// customize filetypes to your needs
"filetypes": ["typescript", "typescriptreact", "graphql"],
"settings": {
"graphql-config.load.legacy": true
}
}
}
```

this would allow for legacy `graphql-config` file formats like `.graphqlconfig`, useful on projects maintaining compatibility with the intellij plugin

### Using the command-line interface

`graphql-lsp server --schema=localhost:3000`
```sh
graphql-lsp server --schema=localhost:3000
```

The node executable contains several commands: `server` and the command-line language service methods (`validate`, `autocomplete`, `outline`).

```text
GraphQL Language Service Command-Line Interface.
### CLI Options

```
Usage: graphql-lsp <command> <file>
[-h | --help][-c | --configdir] {configDir}
Expand Down
12 changes: 7 additions & 5 deletions packages/graphql-language-service-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,22 @@ The graphql-config features we support are:
module.exports = {
extensions: {
// add customDirectives *legacy*. you can now provide multiple schema pointers to config.schema/project.schema, including inline strings
customDirectives: ["@myExampleDirective"],
customDirectives: ['@myExampleDirective'],
// a function that returns rules array with parameter `ValidationContext` from `graphql/validation`
customValidationRules: require('./config/customValidationRules'),
languageService: {
// should the language service read schema for lookups from a cached file based on graphql config output?
cacheSchemaFileForLookup: true
cacheSchemaFileForLookup: true,
// NOTE: this will disable all definition lookup for local SDL files
}
}
}
},
},
};
```

we also load `require('dotenv').config()`, so you can use process.env variables from local `.env` files!

<span id="workspace-configuration" />

### Workspace Configuration

The LSP Server reads config by sending `workspace/configuration` method when it initializes.
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-language-service-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@babel/types": "^7.17.0",
"@babel/parser": "^7.17.3",
"dotenv": "8.2.0",
"graphql-config": "^4.1.0",
"graphql-config": "^4.3.0",
"graphql-language-service": "^5.0.1",
"mkdirp": "^1.0.4",
"node-fetch": "^2.6.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-language-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"graphql": "^15.5.0 || ^16.0.0"
},
"dependencies": {
"graphql-config": "^4.1.0",
"vscode-languageserver-types": "^3.15.1",
"nullthrows": "^1.0.0"
},
Expand All @@ -41,6 +40,7 @@
"@types/json-schema": "7.0.9",
"benchmark": "^2.1.4",
"graphql": "16.0.0-experimental-stream-defer.5",
"graphql-config": "^4.3.0",
"lodash": "^4.17.15",
"platform": "^1.3.5",
"ts-node": "^8.10.2",
Expand Down
33 changes: 17 additions & 16 deletions packages/monaco-graphql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,19 @@ window.MonacoEnvironment = {

// the language service will be instantiated once the schema is available
const MonacoGraphQLAPI = initializeMode({
schemas: [{
// anything that monaco.URI.from() is compatible with
uri: 'https://myschema.com',
// match the monaco file uris for this schema.
// accepts specific filenames and anything `picomatch` supports.
fileMatch: ["**/*.graphql"],
schema: myGraphqlSchema as GraphQLSchema
}],
})

schemas: [
{
// anything that monaco.URI.from() is compatible with
uri: 'https://myschema.com',
// match the monaco file uris for this schema.
// accepts specific filenames and anything `picomatch` supports.
fileMatch: ['**/*.graphql'],
schema: myGraphqlSchema as GraphQLSchema,
},
],
});

const operationModel = monaco.editor.createModel(
const operationModel = monaco.editor.createModel(
'query {}',
'graphql',
'/operation.graphql',
Expand Down Expand Up @@ -201,12 +202,12 @@ MonacoGraphQLAPI.setDiagnosticSettings({
// and compute the json schema using the GraphQLWorker.
// This is in the main process is applied to the global monaco json settings
// for validation, completion and more using monaco-json's built-in JSON Schema support.
[operationModel.uri.toString()]: [variablesModel.uri.toString()]
[operationModel.uri.toString()]: [variablesModel.uri.toString()],
},
jsonDiagnosticSettings: {
allowComments: true, // allow json, parse with a jsonc parser to make requests
}
})
},
});
// TODO: document manual alternative approach
```

Expand Down Expand Up @@ -266,13 +267,13 @@ or you can load the language features only when you have your schema
```ts
import { initializeMode } from 'monaco-graphql/esm/initializeMode';

const schemas = [
const schemas = [
{
schema: GraphQLSchema,
fileMatch: ['operations/*.graphql'],
uri: 'myschema.graphql',
},
]
];
const api = intializeMode({ schemas });

// add another schema. this will cause language workers and features to reset
Expand Down
3 changes: 1 addition & 2 deletions packages/vscode-graphql/.vscodeignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
.vscode/**
.vscode-test/**
out/test/**
out/**/*.map
src/**
.gitignore
node_modules
tsconfig.json
vsc-extension-quickstart.md
tslint.json
node_modules
.github
renovate.json
30 changes: 30 additions & 0 deletions packages/vscode-graphql/esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const { build } = require('esbuild');
const [, , arg] = process.argv;

const logger = console.log;

build({
entryPoints: ['src/extension.ts', 'src/server/index.ts'],
bundle: true,
minify: arg === '--minify',
platform: 'node',
outdir: 'out/',
external: ['vscode'],
format: 'cjs',
sourcemap: true,
watch: arg === '--watch',
})
.then(({ errors, warnings }) => {
if (warnings.length) {
logger.warn(...warnings);
}
if (errors.length) {
logger.error(...errors);
}
logger.log('successfully bundled vscode-graphql 🚀');
process.exit();
})
.catch(err => {
logger.error(err);
process.exit(1);
});
37 changes: 5 additions & 32 deletions packages/vscode-graphql/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vscode-graphql",
"version": "0.4.0",
"version": "0.4.1",
"preview": true,
"private": true,
"license": "MIT",
Expand Down Expand Up @@ -152,20 +152,6 @@
"default": false,
"description": "Enable debug logs"
},
"vscode-graphql.trace.server": {
"type": [
"string"
],
"default": "off",
"description": "Enable tracing for language server"
},
"vscode-graphql.showExecCodelens": {
"type": [
"boolean"
],
"description": "Show codelens to execute operations inline",
"default": true
},
"vscode-graphql.cacheSchemaFileForLookup": {
"type": [
"boolean"
Expand Down Expand Up @@ -216,49 +202,36 @@
}
},
"commands": [
{
"command": "vscode-graphql.isDebugging",
"title": "VSCode GraphQL: Is Debugging?"
},
{
"command": "vscode-graphql.restart",
"title": "VSCode GraphQL: Manual Restart"
},
{
"command": "vscode-graphql.showOutputChannel",
"title": "VSCode GraphQL: Show output channel"
},
{
"command": "vscode-graphql.contentProvider",
"title": "VSCode GraphQL: Execute GraphQL Operations"
}
]
},
"scripts": {
"vscode:prepublish": "npm run compile -- --minify",
"compile": "npm run compile:server && esbuild ./dist/extension.js --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node",
"compile:server": "esbuild ./dist/server/index.js --bundle --outfile=out/server/server.js --external:vscode --format=cjs --platform=node",
"compile": "node esbuild",
"build-bundles": "npm run compile -- --sourcemap",
"vsce:package": "vsce package --yarn",
"env:source": "export $(cat .envrc | xargs)",
"vsce:publish": "vsce publish --yarn --pat \"$PAT_TOKEN\"",
"open-vsx:publish": "ovsx publish --pat \"$OPEN_VSX_ACCESS_TOKEN\"",
"release": "npm run vsce:publish && npm run open-vsx:publish"
"postpublish": "npm run vsce:publish && npm run open-vsx:publish"
},
"devDependencies": {
"@types/capitalize": "2.0.0",
"@types/vscode": "1.62.0",
"esbuild": "0.13.15",
"esbuild": "0.12.15",
"ovsx": "0.3.0",
"vsce-yarn-patch": "^1.66.2"
"vsce": "^2.7.0"
},
"dependencies": {
"graphql": "16.0.0-experimental-stream-defer.5",
"graphql-config": "^4.1.0",
"graphql-language-service-server": "^2.7.18",
"vscode-languageclient": "5.2.1"
},
"resolutions": {
"graphql-config": "4.1.0"
}
}
2 changes: 1 addition & 1 deletion packages/vscode-graphql/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function activate(context: ExtensionContext) {
console.log('Extension "vscode-graphql" is now active!');
}

const serverPath = path.join('out/server', 'server.js');
const serverPath = path.join('out', 'server', 'index.js');
const serverModule = context.asAbsolutePath(serverPath);

const debugOptions = {
Expand Down
1 change: 0 additions & 1 deletion packages/vscode-graphql/src/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'babel-polyfill';
import { startServer } from 'graphql-language-service-server';

// The npm scripts are configured to only build this once before
Expand Down
1 change: 1 addition & 0 deletions packages/vscode-graphql/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../../resources/tsconfig.base.esm.json",
"compilerOptions": {
"target": "ES2018",
"module": "CommonJS",
"composite": true,
"rootDir": "./src",
"outDir": "./dist"
Expand Down
2 changes: 0 additions & 2 deletions packages/vscode-graphql/yarn.lock

This file was deleted.

Loading

0 comments on commit c36504a

Please sign in to comment.