@graphql-mesh/utils 0.43.17 → 0.43.18-alpha-20230321145025-cc027190e

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.
@@ -2,14 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getHeadersObj = void 0;
4
4
  function headersToJSON(headers) {
5
- const obj = {};
6
- headers.forEach((value, key) => {
7
- obj[key] = value;
8
- });
9
- return obj;
5
+ return Object.fromEntries(headers.entries());
6
+ }
7
+ function isHeaders(headers) {
8
+ return headers != null && 'get' in headers && typeof headers.get === 'function';
10
9
  }
11
10
  function getHeadersObj(headers) {
12
- if (headers == null || !('forEach' in headers)) {
11
+ if (headers == null || !isHeaders(headers)) {
13
12
  return headers;
14
13
  }
15
14
  return new Proxy({}, {
@@ -17,7 +16,7 @@ function getHeadersObj(headers) {
17
16
  if (name === 'toJSON') {
18
17
  return () => headersToJSON(headers);
19
18
  }
20
- return headers.get(name.toString());
19
+ return headers.get(name.toString()) || undefined;
21
20
  },
22
21
  has(_target, name) {
23
22
  if (name === 'toJSON') {
@@ -26,16 +25,30 @@ function getHeadersObj(headers) {
26
25
  return headers.has(name.toString());
27
26
  },
28
27
  ownKeys(_target) {
29
- const keys = [];
30
- headers.forEach((_value, name) => {
31
- keys.push(name);
32
- });
33
- return keys;
28
+ return [...headers.keys()];
34
29
  },
35
30
  set(_target, name, value) {
36
31
  headers.set(name.toString(), value);
37
32
  return true;
38
33
  },
34
+ defineProperty(_target, name, descriptor) {
35
+ if (descriptor.value != null) {
36
+ headers.set(name.toString(), descriptor.value);
37
+ }
38
+ return true;
39
+ },
40
+ getOwnPropertyDescriptor(_target, name) {
41
+ const value = headers.get(name.toString());
42
+ if (value == null) {
43
+ return undefined;
44
+ }
45
+ return {
46
+ configurable: true,
47
+ enumerable: true,
48
+ value,
49
+ writable: true,
50
+ };
51
+ },
39
52
  deleteProperty(_target, name) {
40
53
  headers.delete(name.toString());
41
54
  return true;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.gql = exports.printWithCache = exports.parseWithCache = void 0;
4
- const utils_1 = require("@graphql-tools/utils");
5
4
  const graphql_1 = require("graphql");
5
+ const utils_1 = require("@graphql-tools/utils");
6
6
  const global_lru_cache_js_1 = require("./global-lru-cache.js");
7
7
  const parseCache = (0, global_lru_cache_js_1.createLruCache)(1000, 3600);
8
8
  const printCache = (0, global_lru_cache_js_1.createLruCache)(1000, 3600);
@@ -1,12 +1,11 @@
1
1
  function headersToJSON(headers) {
2
- const obj = {};
3
- headers.forEach((value, key) => {
4
- obj[key] = value;
5
- });
6
- return obj;
2
+ return Object.fromEntries(headers.entries());
3
+ }
4
+ function isHeaders(headers) {
5
+ return headers != null && 'get' in headers && typeof headers.get === 'function';
7
6
  }
8
7
  export function getHeadersObj(headers) {
9
- if (headers == null || !('forEach' in headers)) {
8
+ if (headers == null || !isHeaders(headers)) {
10
9
  return headers;
11
10
  }
12
11
  return new Proxy({}, {
@@ -14,7 +13,7 @@ export function getHeadersObj(headers) {
14
13
  if (name === 'toJSON') {
15
14
  return () => headersToJSON(headers);
16
15
  }
17
- return headers.get(name.toString());
16
+ return headers.get(name.toString()) || undefined;
18
17
  },
19
18
  has(_target, name) {
20
19
  if (name === 'toJSON') {
@@ -23,16 +22,30 @@ export function getHeadersObj(headers) {
23
22
  return headers.has(name.toString());
24
23
  },
25
24
  ownKeys(_target) {
26
- const keys = [];
27
- headers.forEach((_value, name) => {
28
- keys.push(name);
29
- });
30
- return keys;
25
+ return [...headers.keys()];
31
26
  },
32
27
  set(_target, name, value) {
33
28
  headers.set(name.toString(), value);
34
29
  return true;
35
30
  },
31
+ defineProperty(_target, name, descriptor) {
32
+ if (descriptor.value != null) {
33
+ headers.set(name.toString(), descriptor.value);
34
+ }
35
+ return true;
36
+ },
37
+ getOwnPropertyDescriptor(_target, name) {
38
+ const value = headers.get(name.toString());
39
+ if (value == null) {
40
+ return undefined;
41
+ }
42
+ return {
43
+ configurable: true,
44
+ enumerable: true,
45
+ value,
46
+ writable: true,
47
+ };
48
+ },
36
49
  deleteProperty(_target, name) {
37
50
  headers.delete(name.toString());
38
51
  return true;
@@ -1,5 +1,5 @@
1
- import { memoize1 } from '@graphql-tools/utils';
2
1
  import { parse, print } from 'graphql';
2
+ import { memoize1 } from '@graphql-tools/utils';
3
3
  import { createLruCache } from './global-lru-cache.js';
4
4
  const parseCache = createLruCache(1000, 3600);
5
5
  const printCache = createLruCache(1000, 3600);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-mesh/utils",
3
- "version": "0.43.17",
3
+ "version": "0.43.18-alpha-20230321145025-cc027190e",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "*"
@@ -8,7 +8,7 @@
8
8
  "dependencies": {
9
9
  "@graphql-mesh/cross-helpers": "0.3.3",
10
10
  "@graphql-mesh/string-interpolation": "0.4.2",
11
- "@graphql-mesh/types": "0.91.9",
11
+ "@graphql-mesh/types": "0.91.10-alpha-20230321145025-cc027190e",
12
12
  "@graphql-tools/delegate": "9.0.28",
13
13
  "@graphql-tools/utils": "9.2.1",
14
14
  "dset": "3.1.2",
@@ -1,6 +1,6 @@
1
1
  import { GraphQLSchema } from 'graphql';
2
2
  import { DelegationContext, SubschemaConfig, Transform } from '@graphql-tools/delegate';
3
- import { ExecutionResult, ExecutionRequest } from '@graphql-tools/utils';
3
+ import { ExecutionRequest, ExecutionResult } from '@graphql-tools/utils';
4
4
  export declare function applySchemaTransforms(originalWrappingSchema: GraphQLSchema, subschemaConfig: SubschemaConfig, transformedSchema: GraphQLSchema, transforms?: Transform[]): GraphQLSchema;
5
5
  export declare function applyRequestTransforms(originalRequest: ExecutionRequest, delegationContext: DelegationContext, transformationContext: Record<string, any>, transforms: Transform[]): ExecutionRequest<any, any, any, Record<string, any>, any>;
6
6
  export declare function applyResultTransforms(originalResult: ExecutionResult, delegationContext: DelegationContext, transformationContext: Record<string, any>, transforms: Transform[]): ExecutionResult<any, any>;
@@ -1,6 +1,6 @@
1
1
  import { GraphQLSchema } from 'graphql';
2
2
  import { DelegationContext, SubschemaConfig, Transform } from '@graphql-tools/delegate';
3
- import { ExecutionResult, ExecutionRequest } from '@graphql-tools/utils';
3
+ import { ExecutionRequest, ExecutionResult } from '@graphql-tools/utils';
4
4
  export declare function applySchemaTransforms(originalWrappingSchema: GraphQLSchema, subschemaConfig: SubschemaConfig, transformedSchema: GraphQLSchema, transforms?: Transform[]): GraphQLSchema;
5
5
  export declare function applyRequestTransforms(originalRequest: ExecutionRequest, delegationContext: DelegationContext, transformationContext: Record<string, any>, transforms: Transform[]): ExecutionRequest<any, any, any, Record<string, any>, any>;
6
6
  export declare function applyResultTransforms(originalResult: ExecutionResult, delegationContext: DelegationContext, transformationContext: Record<string, any>, transforms: Transform[]): ExecutionResult<any, any>;
@@ -1 +1 @@
1
- export declare function getHeadersObj(headers: Headers): Record<string, string>;
1
+ export declare function getHeadersObj(headers: Headers | Record<string, string>): Record<string, string>;
@@ -1 +1 @@
1
- export declare function getHeadersObj(headers: Headers): Record<string, string>;
1
+ export declare function getHeadersObj(headers: Headers | Record<string, string>): Record<string, string>;
@@ -1,4 +1,4 @@
1
- import { HookName, AllHooks, MeshPubSub } from '@graphql-mesh/types';
1
+ import { AllHooks, HookName, MeshPubSub } from '@graphql-mesh/types';
2
2
  type Listener<THookName extends HookName = HookName> = (data: AllHooks[THookName]) => void;
3
3
  export declare class PubSub implements MeshPubSub {
4
4
  private subIdListenerMap;
@@ -1,4 +1,4 @@
1
- import { HookName, AllHooks, MeshPubSub } from '@graphql-mesh/types';
1
+ import { AllHooks, HookName, MeshPubSub } from '@graphql-mesh/types';
2
2
  type Listener<THookName extends HookName = HookName> = (data: AllHooks[THookName]) => void;
3
3
  export declare class PubSub implements MeshPubSub {
4
4
  private subIdListenerMap;