Socket
Socket
Sign inDemoInstall

graphql-language-service

Package Overview
Dependencies
Maintainers
4
Versions
239
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-language-service


Version published
Weekly downloads
357K
increased by3.33%
Maintainers
4
Created
Weekly downloads
 

Package description

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

Last updated on 10 Aug 2017

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc