Socket
Socket
Sign inDemoInstall

graphql-filter-fragment

Package Overview
Dependencies
35
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    graphql-filter-fragment

Filters a data structure by a GraphQL fragment


Version published
Weekly downloads
5.3K
decreased by-14.22%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

graphql-filter-fragment

Filters a data structure by a GraphQL fragment.

Example

import filterGraphQlFragment from 'graphql-filter-fragment';
import {gql} from '@apollo/client/core';

const result = filterGraphQlFragment(
  gql`
    fragment museum on Museum {
      name
      address {
        city
      }
    }
  `,
  {
    name: 'Museum of Popular Culture',
    address: {
      street: '325 5th Ave N',
      city: 'Seattle'
    }
  }
);

expect(result).toEqual({
  name: 'Museum of Popular Culture',
  address: {
    city: 'Seattle'
  }
});

Why?

This utility function is helpful to remove read-only fields before mutations if the data was fetched previously.

Credits

All credit goes to the graphql-anywhere package which is unfortunately not maintained anymore and the utilities no longer included in recent @apollo/client versions. The code in this repo is a direct copy-paste from the original code with an updated peer dependency version of graphql.

Keywords

FAQs

Last updated on 30 Sep 2022

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