Socket
Socket
Sign inDemoInstall

graphql-language-service

Package Overview
Dependencies
Maintainers
14
Versions
241
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-language-service

The official, runtime independent Language Service for GraphQL


Version published
Weekly downloads
396K
increased by0.69%
Maintainers
14
Weekly downloads
 
Created

What is graphql-language-service?

The graphql-language-service npm package provides a set of tools and utilities for working with GraphQL language features. It includes functionalities such as parsing, validation, and autocompletion, which are essential for building GraphQL development tools and editors.

What are graphql-language-service's main functionalities?

Parsing

This feature allows you to parse a GraphQL query string into an Abstract Syntax Tree (AST). The AST can then be used for further analysis or transformation.

const { parse } = require('graphql-language-service-parser');
const query = `query { user(id: 1) { name } }`;
const ast = parse(query);
console.log(JSON.stringify(ast, null, 2));

Validation

This feature allows you to validate a GraphQL query against a schema. It helps in identifying errors and ensuring that the query adheres to the schema's rules.

const { validate } = require('graphql');
const { parse } = require('graphql-language-service-parser');
const { specifiedRules } = require('graphql-language-service');
const schema = /* GraphQLSchema object */;
const query = `query { user(id: 1) { name } }`;
const ast = parse(query);
const errors = validate(schema, ast, specifiedRules);
console.log(errors);

Autocomplete

This feature provides autocompletion suggestions for a given position in a GraphQL query. It is useful for building IDE extensions and other developer tools that enhance the GraphQL development experience.

const { getAutocompleteSuggestions } = require('graphql-language-service-interface');
const schema = /* GraphQLSchema object */;
const query = `query { user(`;
const position = { line: 0, character: 12 };
const suggestions = getAutocompleteSuggestions(schema, query, position);
console.log(suggestions);

Other packages similar to graphql-language-service

Keywords

FAQs

Package last updated on 13 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc