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

apollo-utilities

Package Overview
Dependencies
Maintainers
4
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-utilities

Utilities for working with GraphQL ASTs

  • 1.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3M
increased by7.39%
Maintainers
4
Weekly downloads
 
Created

What is apollo-utilities?

The apollo-utilities package provides a set of utility functions for working with GraphQL data in Apollo Client. These utilities help with tasks such as parsing, transforming, and comparing GraphQL queries and results.

What are apollo-utilities's main functionalities?

GraphQL Query Parsing

This feature allows you to parse a GraphQL query and extract the operation definition. The code sample demonstrates how to use the `getOperationDefinition` function to parse a query and log the operation definition.

const { getOperationDefinition } = require('apollo-utilities');
const gql = require('graphql-tag');

const query = gql`
  query GetUser {
    user(id: 1) {
      id
      name
    }
  }
`;

const operationDefinition = getOperationDefinition(query);
console.log(operationDefinition);

Deep Equality Check

This feature provides a deep equality check for comparing two objects. The code sample demonstrates how to use the `isEqual` function to compare two nested objects.

const { isEqual } = require('apollo-utilities');

const obj1 = { a: 1, b: { c: 2 } };
const obj2 = { a: 1, b: { c: 2 } };

console.log(isEqual(obj1, obj2)); // true

Query Transformation

This feature allows you to transform a GraphQL query by adding `__typename` fields to it. The code sample demonstrates how to use the `addTypenameToDocument` function to transform a query.

const { addTypenameToDocument } = require('apollo-utilities');
const gql = require('graphql-tag');

const query = gql`
  query GetUser {
    user(id: 1) {
      id
      name
    }
  }
`;

const transformedQuery = addTypenameToDocument(query);
console.log(transformedQuery);

Other packages similar to apollo-utilities

FAQs

Package last updated on 21 May 2019

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