@graphql-tools/resolvers-composition 6.4.14 → 6.5.0-alpha-b76ec274.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.
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chainFunctions = void 0;
4
+ function chainFunctions(funcs) {
5
+ if (funcs.length === 1) {
6
+ return funcs[0];
7
+ }
8
+ return funcs.reduce((a, b) => (...args) => a(b(...args)));
9
+ }
10
+ exports.chainFunctions = chainFunctions;
package/cjs/index.js ADDED
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./resolvers-composition.js"), exports);
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -1,20 +1,11 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
- const _ = _interopDefault(require('lodash'));
8
- const utils = require('@graphql-tools/utils');
9
- const micromatch = _interopDefault(require('micromatch'));
10
-
11
- function chainFunctions(funcs) {
12
- if (funcs.length === 1) {
13
- return funcs[0];
14
- }
15
- return funcs.reduce((a, b) => (...args) => a(b(...args)));
16
- }
17
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.composeResolvers = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const chain_functions_js_1 = require("./chain-functions.js");
6
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
7
+ const utils_1 = require("@graphql-tools/utils");
8
+ const micromatch_1 = tslib_1.__importDefault(require("micromatch"));
18
9
  function isScalarTypeConfiguration(config) {
19
10
  return config && 'serialize' in config && 'parseLiteral' in config;
20
11
  }
@@ -23,14 +14,14 @@ function resolveRelevantMappings(resolvers, path) {
23
14
  return [];
24
15
  }
25
16
  const [typeNameOrGlob, fieldNameOrGlob] = path.split('.');
26
- const isTypeMatch = micromatch.matcher(typeNameOrGlob);
17
+ const isTypeMatch = micromatch_1.default.matcher(typeNameOrGlob);
27
18
  let fixedFieldGlob = fieldNameOrGlob;
28
19
  // convert single value OR `{singleField}` to `singleField` as matching will fail otherwise
29
20
  if (fixedFieldGlob.includes('{') && !fixedFieldGlob.includes(',')) {
30
21
  fixedFieldGlob = fieldNameOrGlob.replace('{', '').replace('}', '');
31
22
  }
32
23
  fixedFieldGlob = fixedFieldGlob.replace(', ', ',').trim();
33
- const isFieldMatch = micromatch.matcher(fixedFieldGlob);
24
+ const isFieldMatch = micromatch_1.default.matcher(fixedFieldGlob);
34
25
  const mappings = [];
35
26
  for (const typeName in resolvers) {
36
27
  if (!isTypeMatch(typeName)) {
@@ -79,7 +70,7 @@ function composeResolvers(resolvers, mapping = {}) {
79
70
  const composeFns = resolverPathMapping;
80
71
  const relevantFields = resolveRelevantMappings(resolvers, resolverPath);
81
72
  for (const path of relevantFields) {
82
- mappingResult[path] = utils.asArray(composeFns);
73
+ mappingResult[path] = (0, utils_1.asArray)(composeFns);
83
74
  }
84
75
  }
85
76
  else if (resolverPathMapping) {
@@ -87,16 +78,15 @@ function composeResolvers(resolvers, mapping = {}) {
87
78
  const composeFns = resolverPathMapping[fieldName];
88
79
  const relevantFields = resolveRelevantMappings(resolvers, resolverPath + '.' + fieldName);
89
80
  for (const path of relevantFields) {
90
- mappingResult[path] = utils.asArray(composeFns);
81
+ mappingResult[path] = (0, utils_1.asArray)(composeFns);
91
82
  }
92
83
  }
93
84
  }
94
85
  }
95
86
  for (const path in mappingResult) {
96
- const fns = chainFunctions([...utils.asArray(mappingResult[path]), () => _.get(resolvers, path)]);
97
- _.set(resolvers, path, fns());
87
+ const fns = (0, chain_functions_js_1.chainFunctions)([...(0, utils_1.asArray)(mappingResult[path]), () => lodash_1.default.get(resolvers, path)]);
88
+ lodash_1.default.set(resolvers, path, fns());
98
89
  }
99
90
  return resolvers;
100
91
  }
101
-
102
92
  exports.composeResolvers = composeResolvers;
@@ -0,0 +1,6 @@
1
+ export function chainFunctions(funcs) {
2
+ if (funcs.length === 1) {
3
+ return funcs[0];
4
+ }
5
+ return funcs.reduce((a, b) => (...args) => a(b(...args)));
6
+ }
package/esm/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './resolvers-composition.js';
@@ -1,14 +1,7 @@
1
+ import { chainFunctions } from './chain-functions.js';
1
2
  import _ from 'lodash';
2
3
  import { asArray } from '@graphql-tools/utils';
3
4
  import micromatch from 'micromatch';
4
-
5
- function chainFunctions(funcs) {
6
- if (funcs.length === 1) {
7
- return funcs[0];
8
- }
9
- return funcs.reduce((a, b) => (...args) => a(b(...args)));
10
- }
11
-
12
5
  function isScalarTypeConfiguration(config) {
13
6
  return config && 'serialize' in config && 'parseLiteral' in config;
14
7
  }
@@ -65,7 +58,7 @@ function resolveRelevantMappings(resolvers, path) {
65
58
  * @param mapping - resolvers composition mapping
66
59
  * @hidden
67
60
  */
68
- function composeResolvers(resolvers, mapping = {}) {
61
+ export function composeResolvers(resolvers, mapping = {}) {
69
62
  const mappingResult = {};
70
63
  for (const resolverPath in mapping) {
71
64
  const resolverPathMapping = mapping[resolverPath];
@@ -92,5 +85,3 @@ function composeResolvers(resolvers, mapping = {}) {
92
85
  }
93
86
  return resolvers;
94
87
  }
95
-
96
- export { composeResolvers };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@graphql-tools/resolvers-composition",
3
- "version": "6.4.14",
3
+ "version": "6.5.0-alpha-b76ec274.0",
4
4
  "description": "Common package containing utils and types for GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
8
8
  },
9
9
  "dependencies": {
10
- "@graphql-tools/utils": "8.7.0",
10
+ "@graphql-tools/utils": "8.8.0-alpha-b76ec274.0",
11
11
  "lodash": "4.17.21",
12
12
  "micromatch": "^4.0.4",
13
13
  "tslib": "^2.4.0"
@@ -19,21 +19,42 @@
19
19
  },
20
20
  "author": "Dotan Simha <dotansimha@gmail.com>",
21
21
  "license": "MIT",
22
- "main": "index.js",
23
- "module": "index.mjs",
24
- "typings": "index.d.ts",
22
+ "main": "cjs/index.js",
23
+ "module": "esm/index.js",
24
+ "typings": "typings/index.d.ts",
25
25
  "typescript": {
26
- "definition": "index.d.ts"
26
+ "definition": "typings/index.d.ts"
27
27
  },
28
+ "type": "module",
28
29
  "exports": {
29
30
  ".": {
30
- "require": "./index.js",
31
- "import": "./index.mjs"
31
+ "require": {
32
+ "types": "./typings/index.d.ts",
33
+ "default": "./cjs/index.js"
34
+ },
35
+ "import": {
36
+ "types": "./typings/index.d.ts",
37
+ "default": "./esm/index.js"
38
+ },
39
+ "default": {
40
+ "types": "./typings/index.d.ts",
41
+ "default": "./esm/index.js"
42
+ }
32
43
  },
33
44
  "./*": {
34
- "require": "./*.js",
35
- "import": "./*.mjs"
45
+ "require": {
46
+ "types": "./typings/*.d.ts",
47
+ "default": "./cjs/*.js"
48
+ },
49
+ "import": {
50
+ "types": "./typings/*.d.ts",
51
+ "default": "./esm/*.js"
52
+ },
53
+ "default": {
54
+ "types": "./typings/*.d.ts",
55
+ "default": "./esm/*.js"
56
+ }
36
57
  },
37
58
  "./package.json": "./package.json"
38
59
  }
39
- }
60
+ }
@@ -0,0 +1 @@
1
+ export * from './resolvers-composition.js';
package/README.md DELETED
@@ -1,5 +0,0 @@
1
- Check API Reference for more information about this package;
2
- https://www.graphql-tools.com/docs/api/modules/resolvers_composition_src
3
-
4
- You can also learn more about Resolvers Composition in this chapter;
5
- https://www.graphql-tools.com/docs/resolvers-composition
package/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './resolvers-composition';