Socket
Socket
Sign inDemoInstall

@graphql-tools/wrap

Package Overview
Dependencies
Maintainers
3
Versions
1301
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-tools/wrap

A set of utils for faster development of GraphQL tools


Version published
Weekly downloads
3.6M
increased by0.52%
Maintainers
3
Weekly downloads
 
Created

What is @graphql-tools/wrap?

The @graphql-tools/wrap package is part of the GraphQL Tools ecosystem, which provides a set of utilities for working with GraphQL schemas. Specifically, @graphql-tools/wrap allows you to transform, extend, and modify existing GraphQL schemas in a flexible and powerful way. This can be particularly useful for gateway services, schema stitching, or when you need to adjust a third-party GraphQL API to fit your application's needs.

What are @graphql-tools/wrap's main functionalities?

Schema Wrapping

This feature allows you to create a new schema by wrapping an existing one, applying various transformations such as renaming types. This is useful for integrating external schemas without causing naming conflicts.

const { wrapSchema, RenameTypes } = require('@graphql-tools/wrap');
const remoteSchema = await introspectSchema(fetcher);
const wrappedSchema = wrapSchema({
  schema: remoteSchema,
  transforms: [new RenameTypes((name) => `Prefixed_${name}`)]
});

Schema Delegation

Schema delegation enables you to delegate a query or mutation to another schema. This is particularly useful in schema stitching or when working with multiple underlying GraphQL APIs.

const { delegateToSchema } = require('@graphql-tools/wrap');
const result = await delegateToSchema({
  schema: wrappedSchema,
  operation: 'query',
  fieldName: 'someField',
  args: { id: '123' },
  context,
  info
});

Filtering Types

This feature allows you to filter out types from a schema based on a condition. It's useful for exposing only a subset of the schema to certain clients.

const { FilterTypes } = require('@graphql-tools/wrap');
const filteredSchema = wrapSchema({
  schema: originalSchema,
  transforms: [new FilterTypes((type) => Boolean(type.name.match(/^Public/)))]
});

Other packages similar to @graphql-tools/wrap

FAQs

Package last updated on 01 May 2021

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc