You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

graphql-language-service-parser

Package Overview
Dependencies
Maintainers
13
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-language-service-parser

An online parser for GraphQL for use in syntax-highlighters and code intelligence tools


Version published
Maintainers
13
Created

Package description

What is graphql-language-service-parser?

The graphql-language-service-parser npm package provides tools for parsing GraphQL queries and schemas. It is useful for building GraphQL language services, such as syntax highlighting, auto-completion, and error checking in IDEs.

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

Parsing GraphQL Queries

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 manipulation.

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

Handling Syntax Errors

This feature helps in identifying and handling syntax errors in GraphQL queries. The parser throws an error if the query is not syntactically correct, which can be caught and handled appropriately.

const { parse } = require('graphql-language-service-parser');
const query = `{
  user(id: "1") {
    name
    age
  }
`;
try {
  const ast = parse(query);
} catch (error) {
  console.error('Syntax Error:', error.message);
}

Locating Nodes in AST

This feature allows you to locate specific nodes in the AST based on a character offset. It is useful for features like syntax highlighting and error reporting in IDEs.

const { parse, getLocation } = require('graphql-language-service-parser');
const query = `{
  user(id: "1") {
    name
    age
  }
}`;
const ast = parse(query);
const location = getLocation(query, 10);
console.log(location);

Other packages similar to graphql-language-service-parser

Readme

Source

graphql-language-service-parser

NPM npm downloads License API Docs Discord Channel

An online immutable parser for GraphQL, designed to be used as part of syntax-highlighting and code intelligence tools such as for the GraphQL Language Service and codemirror-graphql.

Keywords

FAQs

Package last updated on 06 Dec 2021

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc