graphql-language-service-cli (original) (raw)

graphql-language-service-cli

Note: As of 3.0.0, this package has been renamed fromgraphql-language-service to graphql-language-service-cli. please now use the graphql-lsp bin, instead of the graphql binary.

NPM npm downloads Snyk Vulnerabilities for npm package License

We welcome your feedback and suggestions.

GraphQL Language Service provides an interface for building GraphQL language services for IDEs.

Almost 100% forMicrosoft's Language Server Protocolis in place

Supported features include:

see more information atgraphql-language-service-server

Installation and Usage

Dependencies

An LSP-compatible client with a file watcher that sends watch notifications to the server.

DROPPED: GraphQL Language Service no longer depends onWatchman

Only node 9 or greater, and npm or yarn are required dependencies.

Installation

with yarn:

yarn global add graphql-language-service-cli

with npm:

npm install -g graphql-language-service-cli

either will install the graphql-lsp bin globally

GraphQL configuration file (.graphqlrc.yml)

Check out graphql-config

The custom graphql language configurations are:

LSP Workspace Configuration

When running server, your LSP-compatible client canprovide additional workspace configuration.

For example, coc.nvim allows for providing custom settings

"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

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

CLI Options

Usage: graphql-lsp <command> <file>

[-h | --help][-c | --configDir] {configDir}
[-t | --text] {textBuffer}
[-f | --file] {filePath}
[-s | --schema] {schemaPath}

Options:

-h, --help Show help [boolean]

-t, --text Text buffer to perform GraphQL diagnostics on.
Will defer to --file option if omitted.
Overrides the --file option, if any.
[string]

-f, --file File path to perform GraphQL diagnostics on.
Will be ignored if --text option is supplied.
[string]

--row A row number from the cursor location for GraphQL
autocomplete suggestions.
If omitted, the last row number will be used.
[number]

--column A column number from the cursor location for GraphQL
autocomplete suggestions.
If omitted, the last column number will be used.
[number]

-c, --configDir Path to the .graphqlrc.yml configuration file.
Walks up the directory tree from the provided config
directory, or the current working directory, until a
.graphqlrc is found or the root directory is found.
[string]

-s, --schemaPath a path to schema DSL file
[string]

At least one command is required.
Commands: "server, validate, autocomplete, outline"