@envelop/dataloader 3.4.0-alpha-c0cc559.0 → 3.4.0-alpha-e9434aa.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,6 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useDataLoader = void 0;
5
4
  const useDataLoader = (name, builderFn) => {
6
5
  return {
7
6
  onContextBuilding({ context, extendContext }) {
@@ -11,5 +10,4 @@ const useDataLoader = (name, builderFn) => {
11
10
  },
12
11
  };
13
12
  };
14
-
15
13
  exports.useDataLoader = useDataLoader;
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useDataLoader = void 0;
1
4
  const useDataLoader = (name, builderFn) => {
2
5
  return {
3
6
  onContextBuilding({ context, extendContext }) {
@@ -7,5 +10,4 @@ const useDataLoader = (name, builderFn) => {
7
10
  },
8
11
  };
9
12
  };
10
-
11
- export { useDataLoader };
13
+ exports.useDataLoader = useDataLoader;
package/package.json CHANGED
@@ -1,34 +1,56 @@
1
1
  {
2
2
  "name": "@envelop/dataloader",
3
- "version": "3.4.0-alpha-c0cc559.0",
3
+ "version": "3.4.0-alpha-e9434aa.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "2.4.0-alpha-c0cc559.0",
6
+ "@envelop/core": "2.4.0-alpha-e9434aa.0",
7
7
  "dataloader": "^2.0.0",
8
8
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
9
9
  },
10
+ "dependencies": {},
10
11
  "repository": {
11
12
  "type": "git",
12
- "url": "https://github.com/dotansimha/envelop.git",
13
+ "url": "https://github.com/n1ru4l/envelop.git",
13
14
  "directory": "packages/plugins/dataloader"
14
15
  },
15
16
  "author": "Dotan Simha <dotansimha@gmail.com>",
16
17
  "license": "MIT",
17
- "main": "index.js",
18
- "module": "index.mjs",
19
- "typings": "index.d.ts",
18
+ "main": "cjs/index.js",
19
+ "module": "esm/index.js",
20
+ "typings": "typings/index.d.ts",
20
21
  "typescript": {
21
- "definition": "index.d.ts"
22
+ "definition": "typings/index.d.ts"
22
23
  },
24
+ "type": "module",
23
25
  "exports": {
24
26
  ".": {
25
- "require": "./index.js",
26
- "import": "./index.mjs"
27
+ "require": {
28
+ "types": "./typings/index.d.ts",
29
+ "default": "./cjs/index.js"
30
+ },
31
+ "import": {
32
+ "types": "./typings/index.d.ts",
33
+ "default": "./esm/index.js"
34
+ },
35
+ "default": {
36
+ "types": "./typings/index.d.ts",
37
+ "default": "./esm/index.js"
38
+ }
27
39
  },
28
40
  "./*": {
29
- "require": "./*.js",
30
- "import": "./*.mjs"
41
+ "require": {
42
+ "types": "./typings/*.d.ts",
43
+ "default": "./cjs/*.js"
44
+ },
45
+ "import": {
46
+ "types": "./typings/*.d.ts",
47
+ "default": "./esm/*.js"
48
+ },
49
+ "default": {
50
+ "types": "./typings/*.d.ts",
51
+ "default": "./esm/*.js"
52
+ }
31
53
  },
32
54
  "./package.json": "./package.json"
33
55
  }
34
- }
56
+ }
File without changes
package/README.md DELETED
@@ -1,40 +0,0 @@
1
- ## `@envelop/dataloader`
2
-
3
- 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 your wish to use.
4
-
5
- ## Getting Started
6
-
7
- ```
8
- yarn add dataloader @envelop/dataloader
9
- ```
10
-
11
- ## Usage Example
12
-
13
- ```ts
14
- import { envelop } from '@envelop/core';
15
- import DataLoader from 'dataloader';
16
- import { useDataLoader } from '@envelop/dataloader';
17
-
18
- const getEnveloped = envelop({
19
- plugins: [
20
- // ... other plugins ...
21
- useDataLoader('users', context => new DataLoader(keys => myBatchGetUsers(keys))),
22
- ],
23
- });
24
- ```
25
-
26
- Then, when you need to use it in your resolvers, just take it from the context:
27
-
28
- ```ts
29
- export const resolvers = {
30
- Query: {
31
- user: (root, args, context, info) => {
32
- return context.users.load(args.id);
33
- },
34
- },
35
- };
36
- ```
37
-
38
- ## Notes
39
-
40
- There are several ways to create and use DataLoader, please refer to: https://github.com/graphql/dataloader#caching-per-request for more details.