@apollo/utils.dropunuseddefinitions
Drop unused definitions from a GraphQL document
Last updated 3 years ago by apollo-bot .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @apollo/utils.dropunuseddefinitions 
SYNC missed versions from official npm registry.

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
}
*/

Current Tags

  • 2.0.0                                ...           latest (3 years ago)

3 Versions

  • 2.0.0                                ...           3 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (2)
Downloads
Today 0
This Week 2
This Month 3
Last Day 2
Last Week 1
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None

Copyright 2013 - present © cnpmjs.org | Home |