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

@apollographql/graphql-language-service-utils

Package Overview
Dependencies
Maintainers
7
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apollographql/graphql-language-service-utils

Utilities to support the GraphQL Language Service

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
214K
decreased by-2.65%
Maintainers
7
Weekly downloads
 
Created

What is @apollographql/graphql-language-service-utils?

@apollographql/graphql-language-service-utils is a utility package designed to assist with GraphQL language services. It provides various tools and utilities to help with tasks such as parsing, validation, and completion of GraphQL queries and schemas.

What are @apollographql/graphql-language-service-utils's main functionalities?

GraphQL Parsing

This feature allows you to parse a GraphQL query string into an Abstract Syntax Tree (AST). The `parse` function takes a query string and returns its AST representation.

const { parse } = require('@apollographql/graphql-language-service-utils');
const query = `query { user(id: 1) { name } }`;
const parsedQuery = parse(query);
console.log(parsedQuery);

GraphQL Validation

This feature allows you to validate a GraphQL query against a schema. The `validate` function takes a schema and a parsed query, and returns an array of validation errors, if any.

const { validate } = require('@apollographql/graphql-language-service-utils');
const { buildSchema } = require('graphql');
const schema = buildSchema(`type Query { user(id: ID!): User } type User { id: ID! name: String }`);
const query = `query { user(id: 1) { name } }`;
const errors = validate(schema, parse(query));
console.log(errors);

GraphQL Completion

This feature provides autocomplete suggestions for a given position in a GraphQL query. The `getAutocompleteSuggestions` function takes a schema, a query string, and a position, and returns a list of suggestions.

const { getAutocompleteSuggestions } = require('@apollographql/graphql-language-service-utils');
const { buildSchema } = require('graphql');
const schema = buildSchema(`type Query { user(id: ID!): User } type User { id: ID! name: String }`);
const query = `query { user(`;
const suggestions = getAutocompleteSuggestions(schema, query, { line: 1, character: 12 });
console.log(suggestions);

Other packages similar to @apollographql/graphql-language-service-utils

Keywords

FAQs

Package last updated on 04 Nov 2018

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