Socket
Book a DemoInstallSign in
Socket

graphql-filter-fragment

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-filter-fragment

Filters a data structure by a GraphQL fragment

1.0.5
latest
npmnpm
Version published
Weekly downloads
8.8K
13.41%
Maintainers
1
Weekly downloads
 
Created
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

graphql

FAQs

Package last updated on 30 Sep 2022

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.