What is graphql-language-service-interface?
The graphql-language-service-interface package provides a set of tools and utilities to support GraphQL language services, such as autocompletion, error checking, and more. It is designed to be used in IDEs and other development environments to enhance the GraphQL development experience.
What are graphql-language-service-interface's main functionalities?
Autocomplete
This feature provides autocompletion suggestions for a given GraphQL query at a specific cursor position. It helps developers by suggesting possible fields, types, and other GraphQL constructs.
const { getAutocompleteSuggestions } = require('graphql-language-service-interface');
const schema = /* GraphQLSchema object */;
const query = '{ user { na } }';
const position = { line: 0, character: 10 };
const suggestions = getAutocompleteSuggestions(schema, query, position);
console.log(suggestions);
Diagnostics
This feature provides diagnostic information for a given GraphQL query, such as syntax errors and validation issues against the provided schema. It helps developers identify and fix issues in their GraphQL queries.
const { getDiagnostics } = require('graphql-language-service-interface');
const schema = /* GraphQLSchema object */;
const query = '{ user { name } }';
const diagnostics = getDiagnostics(query, schema);
console.log(diagnostics);
Hover Information
This feature provides hover information for a given GraphQL query at a specific cursor position. It helps developers by showing detailed information about the GraphQL types, fields, and other constructs under the cursor.
const { getHoverInformation } = require('graphql-language-service-interface');
const schema = /* GraphQLSchema object */;
const query = '{ user { name } }';
const position = { line: 0, character: 7 };
const hoverInfo = getHoverInformation(schema, query, position);
console.log(hoverInfo);
Other packages similar to graphql-language-service-interface
graphql-language-service
The graphql-language-service package provides a complete language server implementation for GraphQL, including features like autocompletion, diagnostics, and more. It is similar to graphql-language-service-interface but offers a more comprehensive set of tools for building GraphQL language services.
graphql-tools
The graphql-tools package provides a set of utilities for building and manipulating GraphQL schemas. While it does not focus on language services like autocompletion and diagnostics, it is useful for schema stitching, mocking, and other schema-related tasks.
graphql
The graphql package is the reference implementation of the GraphQL specification. It provides the core functionality for parsing, validating, and executing GraphQL queries. While it does not offer language service features directly, it is a fundamental building block for any GraphQL-related tooling.