@apollo/utils.dropunuseddefinitions
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

dropUnusedDefinitions

Given an operation document and an operation name, this function will return a new document with only the definitions required for the operation name provided.

If the provided operation name doesn't match any operation in the document, dropUnusedDefinitions will return the original document.

Usage

import { dropUnusedDefinitions } from "@apollo/utils.dropunuseddefinitions";

const operation = parse(`#graphql
  query Drop { ...DroppedFragment }
  fragment DroppedFragment on Query { abc }
  query Keep { ...KeptFragment }
  fragment KeptFragment on Query { def }
`);
const keepOperation = dropUnusedDefinitions(operation, "Keep");
/**
query Keep {
  ...KeptFragment
}

fragment KeptFragment on Query {
  def
}
*/

Package Sidebar

Install

npm i @apollo/utils.dropunuseddefinitions

Weekly Downloads

1,590,766

Version

3.0.0

License

MIT

Unpacked Size

6.58 kB

Total Files

10

Last publish

Collaborators

  • dkuc
  • glasser
  • trevor.scheer
  • apollo-bot