Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql-language-service

Package Overview
Dependencies
Maintainers
14
Versions
243
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

  • 6.0.0-canary-cd4cdaba.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
14
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 08 Jul 2023

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