
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
@envelop/dataloader
Advanced tools
This plugin helps you to create a new [DataLoader](https://github.com/graphql/dataloader) instance every time your context is being built. The created instance is injected into the `context` with the name you wish to use.
@envelop/dataloader
This plugin helps you to create a new DataLoader instance
every time your context is being built. The created instance is injected into the context
with the
name you wish to use.
yarn add dataloader @envelop/dataloader
import DataLoader from 'dataloader'
import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
import { envelop, useEngine } from '@envelop/core'
import { useDataLoader } from '@envelop/dataloader'
const getEnveloped = envelop({
plugins: [
useEngine({ parse, validate, specifiedRules, execute, subscribe }),
// ... other plugins ...
useDataLoader('users', context => new DataLoader(keys => myBatchGetUsers(keys)))
]
})
Then, when you need to use it in your resolvers, just take it from the context:
export const resolvers = {
Query: {
user: (root, args, context, info) => {
return context.users.load(args.id)
}
}
}
There are several ways to create and use DataLoader, please refer to: https://github.com/graphql/dataloader#caching-per-request for more details.
FAQs
This plugin helps you to create a new [DataLoader](https://github.com/graphql/dataloader) instance every time your context is being built. The created instance is injected into the `context` with the name you wish to use.
We found that @envelop/dataloader demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.