Socket
Socket
Sign inDemoInstall

@graphql-tools/optimize

Package Overview
Dependencies
2
Maintainers
3
Versions
74
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @graphql-tools/optimize

A set of utils for faster development of GraphQL tools


Version published
Weekly downloads
3.2M
decreased by-17.64%
Maintainers
3
Install size
97.3 kB
Created
Weekly downloads
 

Readme

Source

GraphQL Tools: DocumentNode Optimizer

This package is intended to allow developers to optimize DocumentNode objects created by graphql library.

It's built as a set of small optimizers you can compose to get the most out of your GraphQL setup.

The goal of this package is mostly around making optimizations for the way the data is stored in DocumentNode, and not to the essence of the DocumentNode.

Getting Started

yarn add -D @graphql-tools/optimize

API

To get started with this tool, import it and run it over your DocumentNode.

import { optimizeDocumentNode } from '@graphql-tools/optimize';

const myDocument: DocumentNode = { ... }
const optimizedDocument = optimizeDocumentNode(myDocument);

Customizing Optimizers

By default, we apply all optimizers available in this repo over your document. It shouldn't effect any runtime since we just remove dead or unused areas.

You can modify the list of optimizers this way:

import { optimizeDocumentNode, removeDescriptions } from '@graphql-tools/optimize';

const myDocument: DocumentNode = { ... }
const optimizedDocument = optimizeDocumentNode(myDocument, [removeDescriptions]);

Writing your own optimizer

You can create your own optimizer to manipulate DocumentNode, the API signature is pretty simple:

export type DocumentOptimizer = (input: DocumentNode) => DocumentNode

Take a look at [./optimizers](this directory for inspiration and implementation reference).

FAQs

Last updated on 19 May 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc