Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
apollo-link-response-resolver
Advanced tools
Use resolvers to format incoming data with Apollo Link
Remote data from an external API doesn't always line up with the format we expect it to be in. From enum values not corresponding to their client-side string representation to float values not being return as a currency string, there are many cases where you need to automatically format incoming data.
apollo-link-response-resolver
is a solution to this problem using a resolver format that GraphQL and Redux users will be comfortable with. You create your resolvers map and hook apollo-link-response-resolver
in to ApolloClient and the rest is automatic--all incoming response data will be formatted based on the resolvers you provided.
To get started, install apollo-link-response-resolver
from npm:
npm install -S apollo-link-response-resolver
The rest of the instructions assume that you have already set up Apollo Client in your application. After you install the package, you can create your response resolver by calling responseResolver
and passing in a resolver map. A resolver map describes how to update the fields on each type of data.
Let's look at a simple example where we're updating the fullname
field on all pieces of data coming from the server with the Account
type:
import { withResponseResolver } from 'apollo-link-response-resolver'
const resolvers = {
Account: {
fullname: name => name.toUpperCase(),
},
}
const responseResolverLink = withResponseResolver(resolvers)
To hook up your response resolvers to Apollo Client, add your link to the other links in your Apollo Link chain. You want to make sure that your link comes before HttpLink
.
const client = new ApolloClient({
cache,
link: ApolloLink.from([responseResolverLink, new HttpLink()]),
})
TODO
FAQs
Use resolvers to format incoming data with Apollo Link
We found that apollo-link-response-resolver demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.