Socket
Socket
Sign inDemoInstall

dataloader-factory

Package Overview
Dependencies
2
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.3.0 to 4.3.1

10

dist/index.js

@@ -123,3 +123,3 @@ "use strict";

this.groupItems = (items, dedupekeys) => {
const ret = {};
const ret = Object.create(null);
for (const item of items) {

@@ -141,3 +141,3 @@ for (const key of dedupekeys.values()) {

this.groupItems = (items) => {
const ret = {};
const ret = Object.create(null);
for (const item of items) {

@@ -173,3 +173,3 @@ pushRecord(ret, this.config.cacheKeyFn(extractFn(item)), item);

groupItems(items) {
const ret = {};
const ret = Object.create(null);
for (const { key, value } of items) {

@@ -200,3 +200,3 @@ pushRecord(ret, this.config.cacheKeyFn(key), value);

this.groupItems = (items, dedupekeys) => {
const ret = {};
const ret = Object.create(null);
for (const item of items) {

@@ -218,3 +218,3 @@ for (const key of dedupekeys.values()) {

this.groupItems = (items) => {
const ret = {};
const ret = Object.create(null);
for (const item of items) {

@@ -221,0 +221,0 @@ for (const key of extractFn(item))

{
"name": "dataloader-factory",
"version": "4.3.0",
"version": "4.3.1",
"description": "DataLoader classes to make it easier to write complex graphql resolvers.",

@@ -5,0 +5,0 @@ "exports": {

@@ -479,8 +479,11 @@ # dataloader-factory

Dataloader has a `.loadMany` method that can be used to retrieve objects based on an
array of keys. However, it is designed to return Errors for any keys that threw an error, so
you have to be aware of that any time you use it. Additionally, keys that do not point at any
data will come back undefined, and you will have undefined values in the returned array.
array of keys. However, it is designed to catch and return Errors for any keys that throw an
error, so you have to be aware of that any time you use it. Additionally, keys that do not
point at any data will come back undefined, and you will have undefined values in the returned
array.
To avoid both of these problems and just get an array of any of the objects that exist, a
`.loadMany` method exists on the factory for your convenience:
To avoid both of these problems, a `.loadMany` method exists on the factory for your convenience.
Its return array only contains objects that exist - no undefined values. Additionally, if
any key throws an error, `loadMany` throws the error instead of catching it and inserting it
into the array.
```javascript

@@ -496,3 +499,4 @@ const books = await ctx.loaders.loadMany(bookLoader, bookIds)

## Mutations
In graphql, after a mutation there will be a query, which can be very complex. If this query
In graphql, mutations have return values, and the user is able to query any number and depth of
properties in that return object. In effect the user has a chance to make a , which may be very complex. If this query
is evaluated after you have already done some dataloading (e.g. to find related objects to help

@@ -499,0 +503,0 @@ authorize the mutation), you will want to get rid of any cached objects that were fetched before

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc