Registry / devops / graphql-language-service

graphql-language-service

JSON →
library5.5.2jsnpmunverified

Official language service for GraphQL, providing LSP-compatible methods for IDEs and editors. Version 5.5.2 supports GraphQL 15.x, 16.x, and 17.x. Maintained by the GraphiQL team, it offers parser, utilities, and interface for building GraphQL IDE features. Includes autocompletion, diagnostics, hover info, go-to-definition, and document symbols. Still somewhat experimental but built on stable libraries. Key differentiator: standalone and runtime independent, designed for use in both Node and browser environments.

npm install graphql-language-service
INSTALL
IMPORT
SIG · GRAPHQL-LANGUAGE-S
G
graphql-language-service
devopsjavascriptv5.5.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GraphQLCache
import { GraphQLCache } from 'graphql-language-service'
const { GraphQLCache } = require('graphql-language-service')
ESM export; CJS require may break in TypeScript. Available after v4.
getAutocompleteSuggestions
import { getAutocompleteSuggestions } from 'graphql-language-service'
Named export, commonly used for autocomplete in editors.
GraphQLLanguageService
import { GraphQLLanguageService } from 'graphql-language-service'
Main class for language service operations. Not to be confused with deprecated GraphQLService from other packages.

Shows how to set up a schema, create a GraphQL cache, and retrieve autocomplete suggestions for a query.

import { GraphQLCache, getAutocompleteSuggestions } from 'graphql-language-service'; import { buildSchema, GraphQLSchema } from 'graphql'; const schema: GraphQLSchema = buildSchema(` type Query { hello: String } `); const cache = new GraphQLCache({ schema }); const suggestions = getAutocompleteSuggestions( schema, '{ h', { column: 4, line: 1 }, cache ); console.log(suggestions); // [{ label: 'hello', ... }]
Debug
Known issues
deprecatedThe CLI interface was moved to graphql-language-service-cli in v3.0.0
fix
Import from 'graphql-language-service-cli' for command line usage.
affects: >=3.0.0
gotchaGraphQLCache requires a schema; missing schema causes runtime errors
fix
Always pass a valid schema object to the constructor.
affects: >=4.0.0
gotchagetAutocompleteSuggestions third argument must be a position object (not string or number)
fix
Use { line: number, column: number } format.
affects: >=5.0.0
breakingv5 dropped support for GraphQL 14.x
fix
Upgrade graphql peer dependency to ^15.5.0 || ^16.0.0 || ^17.0.0
affects: >=5.0.0
gotchaESM-only package will not work with require() in some bundlers
fix
Use import syntax or configure bundler to handle ESM.
affects: >=4.0.0
Errors
Common errors & fixes
Cannot find module 'graphql-language-service'
Missing installation or incorrect import path
fix
npm install graphql-language-service graphql
TypeError: getAutocompleteSuggestions is not a function
Using default import instead of named import
fix
Use import { getAutocompleteSuggestions } from 'graphql-language-service'
GraphQLError: Syntax Error: Expected :, found }
Schema syntax error in buildSchema call
fix
Check GraphQL schema string for correctness.
Upgrade
Version history
5.5.2latest on npm
Audit
Dependencies
graphqlrequiredPeer dependency for GraphQL type system and schema operations
Agent activity
4 hits · last 30 days
node
4
Resources
graphql-language-service — npm install graphql-language-service · libregistry