What is @apollographql/graphql-language-service-interface?
@apollographql/graphql-language-service-interface is a package that provides a set of tools and interfaces for building GraphQL language services. It is designed to help developers create features like auto-completion, error checking, and other language server protocol (LSP) functionalities for GraphQL.
What are @apollographql/graphql-language-service-interface's main functionalities?
Auto-completion
This feature provides auto-completion suggestions for a given GraphQL query based on the schema and the cursor position.
const { getAutocompleteSuggestions } = require('@apollographql/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 (such as errors and warnings) for a given GraphQL query based on the schema.
const { getDiagnostics } = require('@apollographql/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 based on the schema and the cursor position.
const { getHoverInformation } = require('@apollographql/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 @apollographql/graphql-language-service-interface
graphql-language-service
graphql-language-service is a package that provides a set of tools for building GraphQL language services. It includes features like auto-completion, diagnostics, and hover information. It is similar to @apollographql/graphql-language-service-interface but is more comprehensive and includes additional tools for building language services.
graphql-tools
graphql-tools is a package that provides a set of utilities for building and manipulating GraphQL schemas. While it does not provide language service features like auto-completion and diagnostics, it is useful for schema stitching, mocking, and other schema-related tasks. It can be used in conjunction with @apollographql/graphql-language-service-interface to provide a complete GraphQL development experience.
codemirror-graphql
codemirror-graphql is a package that provides a GraphQL mode for the CodeMirror editor. It includes features like syntax highlighting, auto-completion, and error checking. It is similar to @apollographql/graphql-language-service-interface but is specifically designed for use with the CodeMirror editor.