Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@graphql-tools/wrap
Advanced tools
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.
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/)))]
});
Similar to @graphql-tools/wrap, this package is designed to transform existing GraphQL schemas. It focuses specifically on making any GraphQL schema compatible with Apollo Federation, allowing for a more specialized use case compared to the broader transformations possible with @graphql-tools/wrap.
GraphQL Mesh allows you to use other APIs (REST, SOAP, gRPC, and more) as a GraphQL schema. While it provides functionality to transform and extend these schemas similar to @graphql-tools/wrap, it also includes a broader set of features for integrating with non-GraphQL services.
Check API Reference for more information about this package; https://www.graphql-tools.com/docs/api/modules/wrap_src
You can also learn more about Schema Wrapping in this chapter; https://www.graphql-tools.com/docs/schema-wrapping
FAQs
A set of utils for faster development of GraphQL tools
The npm package @graphql-tools/wrap receives a total of 2,707,987 weekly downloads. As such, @graphql-tools/wrap popularity was classified as popular.
We found that @graphql-tools/wrap demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.