npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@divyenduz/graphql-language-server

v1.2.6

Published

An interface for building GraphQL language services for IDEs

Downloads

5

Readme

GraphQL Language Service

Greenkeeper badge

This is currently in technical preview. We welcome your feedback and suggestions.

Build Status

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

Partial support for Microsoft's Language Server Protocol is in place, with more to come in the future.

Currently supported features include:

  • Diagnostics (GraphQL syntax linting/validations) (spec-compliant)
  • Autocomplete suggestions (spec-compliant)
  • Hyperlink to fragment definitions and named types (type, input, enum) definitions (spec-compliant)
  • Outline view support for queries

Installation and Usage

Dependencies

GraphQL Language Service depends on Watchman running on your machine. Follow this installation guide to install Watchman.

Installation

git clone [email protected]:graphql/graphql-language-service.git
cd {path/to/your/repo}
npm install ../graphql-language-service

After pulling the latest changes from this repo, be sure to run npm run build to transform the src/ directory and generate the dist/ directory.

The library includes a node executable file which you can find in ./node_modules/.bin/graphql.js after installation.

GraphQL configuration file (.graphqlconfig)

Check out graphql-config

Using the command-line interface

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

Improving this list is a work-in-progress.

GraphQL Language Service Command-Line Interface.
Usage: bin/graphql.js <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 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"

Architectural Overview

GraphQL Language Service currently communicates via Stream transport with the IDE server. GraphQL server will receive/send RPC messages to perform language service features, while caching the necessary GraphQL artifacts such as fragment definitions, GraphQL schemas etc. More about the server interface and RPC message format below.

The IDE server should launch a separate GraphQL server with its own child process for each .graphqlconfig file the IDE finds (using the nearest ancestor directory relative to the file currently being edited):

./application

  ./productA
    .graphqlconfig
    ProductAQuery.graphql
    ProductASchema.graphql

  ./productB
    .graphqlconfig
    ProductBQuery.graphql
    ProductBSchema.graphql

A separate GraphQL server should be instantiated for ProductA and ProductB, each with its own .graphqlconfig file, as illustrated in the directory structure above.

The IDE server should manage the lifecycle of the GraphQL server. Ideally, the IDE server should spawn a child process for each of the GraphQL Language Service processes necessary, and gracefully exit the processes as the IDE closes. In case of errors or a sudden halt the GraphQL Language Service will close as the stream from the IDE closes.

Server Interface

GraphQL Language Server uses JSON-RPC to communicate with the IDE servers. Microsoft's language server currently supports two communication transports: Stream (stdio) and IPC. For IPC transport, the reference guide to be used for development is the language server protocol documentation.

For each transport, there is a slight difference in JSON message format, especially in how the methods to be invoked are defined - below are the currently supported methods for each transport (will be updated as progress is made):

| | Stream | IPC | | -------------------:|------------------------------|-----------------------------------| | Diagnostics | getDiagnostics | textDocument/publishDiagnostics | | Autocompletion | getAutocompleteSuggestions | textDocument/completion | | Outline | getOutline | Not supported yet | | Go-to definition | getDefinition | Not supported yet | | File Events | Not supported yet | didOpen/didClose/didSave/didChange events |