@graphql-mesh/grpc 1.0.0-alpha-20230523155104-df277a22b → 1.0.0-alpha-20230523160518-5443a1139

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.
package/cjs/index.js CHANGED
@@ -45,7 +45,7 @@ class GrpcHandler {
45
45
  this.pubsub.unsubscribe(subId);
46
46
  });
47
47
  const services = await reflectionClient.listServices();
48
- const userServices = services.filter(service => service && !service?.startsWith('grpc.'));
48
+ const userServices = services.filter(service => service && !(service === null || service === void 0 ? void 0 : service.startsWith('grpc.')));
49
49
  return userServices.map(async (service) => {
50
50
  this.logger.debug(`Resolving root of Service: ${service} from the reflection response`);
51
51
  const serviceRoot = await reflectionClient.fileContainingSymbol(service);
@@ -53,13 +53,14 @@ class GrpcHandler {
53
53
  });
54
54
  }
55
55
  async processDescriptorFile() {
56
+ var _a;
56
57
  let fileName;
57
58
  let options;
58
59
  if (typeof this.config.source === 'object') {
59
60
  fileName = this.config.source.file;
60
61
  options = {
61
62
  ...this.config.source.load,
62
- includeDirs: this.config.source.load.includeDirs?.map(includeDir => cross_helpers_1.path.isAbsolute(includeDir) ? includeDir : cross_helpers_1.path.join(this.baseDir, includeDir)),
63
+ includeDirs: (_a = this.config.source.load.includeDirs) === null || _a === void 0 ? void 0 : _a.map(includeDir => cross_helpers_1.path.isAbsolute(includeDir) ? includeDir : cross_helpers_1.path.join(this.baseDir, includeDir)),
63
64
  };
64
65
  }
65
66
  else {
@@ -91,6 +92,7 @@ class GrpcHandler {
91
92
  return rootFromDescriptor;
92
93
  }
93
94
  async processProtoFile() {
95
+ var _a, _b;
94
96
  this.logger.debug(`Using proto file(s)`);
95
97
  let protoRoot = new Root();
96
98
  let fileGlob;
@@ -103,7 +105,7 @@ class GrpcHandler {
103
105
  options = {
104
106
  ...options,
105
107
  ...this.config.source.load,
106
- includeDirs: this.config.source.load?.includeDirs?.map(includeDir => cross_helpers_1.path.isAbsolute(includeDir) ? includeDir : cross_helpers_1.path.join(this.baseDir, includeDir)),
108
+ includeDirs: (_b = (_a = this.config.source.load) === null || _a === void 0 ? void 0 : _a.includeDirs) === null || _b === void 0 ? void 0 : _b.map(includeDir => cross_helpers_1.path.isAbsolute(includeDir) ? includeDir : cross_helpers_1.path.join(this.baseDir, includeDir)),
107
109
  };
108
110
  if (options.includeDirs) {
109
111
  if (!Array.isArray(options.includeDirs)) {
@@ -200,6 +202,7 @@ class GrpcHandler {
200
202
  return grpcObject;
201
203
  }
202
204
  getServiceClient({ grpcObject, objPath, creds, }) {
205
+ var _a;
203
206
  let serviceClientByObjPath = this.grpcObjectByserviceClientByObjPath.get(grpcObject);
204
207
  if (!serviceClientByObjPath) {
205
208
  serviceClientByObjPath = new Map();
@@ -211,8 +214,7 @@ class GrpcHandler {
211
214
  if (typeof ServiceClient !== 'function') {
212
215
  throw new Error(`Object at path ${objPath} is not a Service constructor`);
213
216
  }
214
- client = new ServiceClient(string_interpolation_1.stringInterpolator.parse(this.config.endpoint, { env: cross_helpers_1.process.env }) ??
215
- this.config.endpoint, creds);
217
+ client = new ServiceClient((_a = string_interpolation_1.stringInterpolator.parse(this.config.endpoint, { env: cross_helpers_1.process.env })) !== null && _a !== void 0 ? _a : this.config.endpoint, creds);
216
218
  const subId = this.pubsub.subscribe('destroy', () => {
217
219
  client.close();
218
220
  this.pubsub.unsubscribe(subId);
@@ -253,7 +255,7 @@ class GrpcHandler {
253
255
  for (const fieldName in rootType.getFields()) {
254
256
  const field = rootType.getFields()[fieldName];
255
257
  const directives = (0, utils_2.getDirectives)(schema, field);
256
- if (directives?.length) {
258
+ if (directives === null || directives === void 0 ? void 0 : directives.length) {
257
259
  for (const directiveObj of directives) {
258
260
  switch (directiveObj.name) {
259
261
  case 'grpcMethod': {
@@ -316,7 +318,7 @@ class GrpcHandler {
316
318
  logger.debug(`Visiting ${currentPath}.nested.values[${key}]`);
317
319
  enumTypeConfig.values[key] = {
318
320
  value,
319
- description: commentMap?.[key],
321
+ description: commentMap === null || commentMap === void 0 ? void 0 : commentMap[key],
320
322
  };
321
323
  }
322
324
  this.schemaComposer.createEnumTC(enumTypeConfig);
@@ -394,7 +396,8 @@ class GrpcHandler {
394
396
  const rootFieldName = [...pathWithName, methodName].join('_');
395
397
  const fieldConfig = {
396
398
  type: () => {
397
- const baseResponseTypePath = method.responseType?.split('.');
399
+ var _a;
400
+ const baseResponseTypePath = (_a = method.responseType) === null || _a === void 0 ? void 0 : _a.split('.');
398
401
  if (baseResponseTypePath) {
399
402
  const responseTypePath = this.walkToFindTypePath(rootJson, pathWithName, baseResponseTypePath);
400
403
  let typeName = (0, utils_js_1.getTypeName)(this.schemaComposer, responseTypePath, false);
@@ -409,10 +412,11 @@ class GrpcHandler {
409
412
  };
410
413
  fieldConfig.args = {
411
414
  input: () => {
415
+ var _a;
412
416
  if (method.requestStream) {
413
417
  return 'File';
414
418
  }
415
- const baseRequestTypePath = method.requestType?.split('.');
419
+ const baseRequestTypePath = (_a = method.requestType) === null || _a === void 0 ? void 0 : _a.split('.');
416
420
  if (baseRequestTypePath) {
417
421
  const requestTypePath = this.walkToFindTypePath(rootJson, pathWithName, baseRequestTypePath);
418
422
  const requestTypeName = (0, utils_js_1.getTypeName)(this.schemaComposer, requestTypePath, true);
@@ -468,8 +472,9 @@ class GrpcHandler {
468
472
  }
469
473
  }
470
474
  async getCachedNonExecutableSchema(creds) {
471
- const interpolatedSource = this.config.source?.toString();
472
- if (interpolatedSource?.endsWith('.graphql')) {
475
+ var _a;
476
+ const interpolatedSource = (_a = this.config.source) === null || _a === void 0 ? void 0 : _a.toString();
477
+ if (interpolatedSource === null || interpolatedSource === void 0 ? void 0 : interpolatedSource.endsWith('.graphql')) {
473
478
  this.logger.info(`Fetching GraphQL Schema with annotations`);
474
479
  const sdl = await (0, utils_1.readFileOrUrl)(interpolatedSource, {
475
480
  allowUnknownExtensions: true,
package/cjs/utils.js CHANGED
@@ -9,7 +9,7 @@ const utils_1 = require("@graphql-mesh/utils");
9
9
  const grpc_js_1 = require("@grpc/grpc-js");
10
10
  const scalars_js_1 = require("./scalars.js");
11
11
  function getTypeName(schemaComposer, pathWithName, isInput) {
12
- if (pathWithName?.length) {
12
+ if (pathWithName === null || pathWithName === void 0 ? void 0 : pathWithName.length) {
13
13
  const baseTypeName = pathWithName.filter(Boolean).join('_');
14
14
  if ((0, scalars_js_1.isScalarType)(baseTypeName)) {
15
15
  return (0, scalars_js_1.getGraphQLScalar)(baseTypeName);
@@ -79,8 +79,9 @@ function addMetaDataToCall(callFn, input, resolverData, metaData, isResponseStre
79
79
  if (isResponseStream) {
80
80
  let isCancelled = false;
81
81
  const responseStreamWithCancel = (0, utils_1.withCancel)(call, () => {
82
+ var _a;
82
83
  if (!isCancelled) {
83
- call.call?.cancelWithStatus(0, 'Cancelled by GraphQL Mesh');
84
+ (_a = call.call) === null || _a === void 0 ? void 0 : _a.cancelWithStatus(0, 'Cancelled by GraphQL Mesh');
84
85
  isCancelled = true;
85
86
  }
86
87
  });
package/esm/index.js CHANGED
@@ -42,7 +42,7 @@ export default class GrpcHandler {
42
42
  this.pubsub.unsubscribe(subId);
43
43
  });
44
44
  const services = await reflectionClient.listServices();
45
- const userServices = services.filter(service => service && !service?.startsWith('grpc.'));
45
+ const userServices = services.filter(service => service && !(service === null || service === void 0 ? void 0 : service.startsWith('grpc.')));
46
46
  return userServices.map(async (service) => {
47
47
  this.logger.debug(`Resolving root of Service: ${service} from the reflection response`);
48
48
  const serviceRoot = await reflectionClient.fileContainingSymbol(service);
@@ -50,13 +50,14 @@ export default class GrpcHandler {
50
50
  });
51
51
  }
52
52
  async processDescriptorFile() {
53
+ var _a;
53
54
  let fileName;
54
55
  let options;
55
56
  if (typeof this.config.source === 'object') {
56
57
  fileName = this.config.source.file;
57
58
  options = {
58
59
  ...this.config.source.load,
59
- includeDirs: this.config.source.load.includeDirs?.map(includeDir => path.isAbsolute(includeDir) ? includeDir : path.join(this.baseDir, includeDir)),
60
+ includeDirs: (_a = this.config.source.load.includeDirs) === null || _a === void 0 ? void 0 : _a.map(includeDir => path.isAbsolute(includeDir) ? includeDir : path.join(this.baseDir, includeDir)),
60
61
  };
61
62
  }
62
63
  else {
@@ -88,6 +89,7 @@ export default class GrpcHandler {
88
89
  return rootFromDescriptor;
89
90
  }
90
91
  async processProtoFile() {
92
+ var _a, _b;
91
93
  this.logger.debug(`Using proto file(s)`);
92
94
  let protoRoot = new Root();
93
95
  let fileGlob;
@@ -100,7 +102,7 @@ export default class GrpcHandler {
100
102
  options = {
101
103
  ...options,
102
104
  ...this.config.source.load,
103
- includeDirs: this.config.source.load?.includeDirs?.map(includeDir => path.isAbsolute(includeDir) ? includeDir : path.join(this.baseDir, includeDir)),
105
+ includeDirs: (_b = (_a = this.config.source.load) === null || _a === void 0 ? void 0 : _a.includeDirs) === null || _b === void 0 ? void 0 : _b.map(includeDir => path.isAbsolute(includeDir) ? includeDir : path.join(this.baseDir, includeDir)),
104
106
  };
105
107
  if (options.includeDirs) {
106
108
  if (!Array.isArray(options.includeDirs)) {
@@ -197,6 +199,7 @@ export default class GrpcHandler {
197
199
  return grpcObject;
198
200
  }
199
201
  getServiceClient({ grpcObject, objPath, creds, }) {
202
+ var _a;
200
203
  let serviceClientByObjPath = this.grpcObjectByserviceClientByObjPath.get(grpcObject);
201
204
  if (!serviceClientByObjPath) {
202
205
  serviceClientByObjPath = new Map();
@@ -208,8 +211,7 @@ export default class GrpcHandler {
208
211
  if (typeof ServiceClient !== 'function') {
209
212
  throw new Error(`Object at path ${objPath} is not a Service constructor`);
210
213
  }
211
- client = new ServiceClient(stringInterpolator.parse(this.config.endpoint, { env: process.env }) ??
212
- this.config.endpoint, creds);
214
+ client = new ServiceClient((_a = stringInterpolator.parse(this.config.endpoint, { env: process.env })) !== null && _a !== void 0 ? _a : this.config.endpoint, creds);
213
215
  const subId = this.pubsub.subscribe('destroy', () => {
214
216
  client.close();
215
217
  this.pubsub.unsubscribe(subId);
@@ -250,7 +252,7 @@ export default class GrpcHandler {
250
252
  for (const fieldName in rootType.getFields()) {
251
253
  const field = rootType.getFields()[fieldName];
252
254
  const directives = getDirectives(schema, field);
253
- if (directives?.length) {
255
+ if (directives === null || directives === void 0 ? void 0 : directives.length) {
254
256
  for (const directiveObj of directives) {
255
257
  switch (directiveObj.name) {
256
258
  case 'grpcMethod': {
@@ -313,7 +315,7 @@ export default class GrpcHandler {
313
315
  logger.debug(`Visiting ${currentPath}.nested.values[${key}]`);
314
316
  enumTypeConfig.values[key] = {
315
317
  value,
316
- description: commentMap?.[key],
318
+ description: commentMap === null || commentMap === void 0 ? void 0 : commentMap[key],
317
319
  };
318
320
  }
319
321
  this.schemaComposer.createEnumTC(enumTypeConfig);
@@ -391,7 +393,8 @@ export default class GrpcHandler {
391
393
  const rootFieldName = [...pathWithName, methodName].join('_');
392
394
  const fieldConfig = {
393
395
  type: () => {
394
- const baseResponseTypePath = method.responseType?.split('.');
396
+ var _a;
397
+ const baseResponseTypePath = (_a = method.responseType) === null || _a === void 0 ? void 0 : _a.split('.');
395
398
  if (baseResponseTypePath) {
396
399
  const responseTypePath = this.walkToFindTypePath(rootJson, pathWithName, baseResponseTypePath);
397
400
  let typeName = getTypeName(this.schemaComposer, responseTypePath, false);
@@ -406,10 +409,11 @@ export default class GrpcHandler {
406
409
  };
407
410
  fieldConfig.args = {
408
411
  input: () => {
412
+ var _a;
409
413
  if (method.requestStream) {
410
414
  return 'File';
411
415
  }
412
- const baseRequestTypePath = method.requestType?.split('.');
416
+ const baseRequestTypePath = (_a = method.requestType) === null || _a === void 0 ? void 0 : _a.split('.');
413
417
  if (baseRequestTypePath) {
414
418
  const requestTypePath = this.walkToFindTypePath(rootJson, pathWithName, baseRequestTypePath);
415
419
  const requestTypeName = getTypeName(this.schemaComposer, requestTypePath, true);
@@ -465,8 +469,9 @@ export default class GrpcHandler {
465
469
  }
466
470
  }
467
471
  async getCachedNonExecutableSchema(creds) {
468
- const interpolatedSource = this.config.source?.toString();
469
- if (interpolatedSource?.endsWith('.graphql')) {
472
+ var _a;
473
+ const interpolatedSource = (_a = this.config.source) === null || _a === void 0 ? void 0 : _a.toString();
474
+ if (interpolatedSource === null || interpolatedSource === void 0 ? void 0 : interpolatedSource.endsWith('.graphql')) {
470
475
  this.logger.info(`Fetching GraphQL Schema with annotations`);
471
476
  const sdl = await readFileOrUrl(interpolatedSource, {
472
477
  allowUnknownExtensions: true,
package/esm/utils.js CHANGED
@@ -5,7 +5,7 @@ import { withCancel } from '@graphql-mesh/utils';
5
5
  import { Metadata, } from '@grpc/grpc-js';
6
6
  import { getGraphQLScalar, isScalarType } from './scalars.js';
7
7
  export function getTypeName(schemaComposer, pathWithName, isInput) {
8
- if (pathWithName?.length) {
8
+ if (pathWithName === null || pathWithName === void 0 ? void 0 : pathWithName.length) {
9
9
  const baseTypeName = pathWithName.filter(Boolean).join('_');
10
10
  if (isScalarType(baseTypeName)) {
11
11
  return getGraphQLScalar(baseTypeName);
@@ -73,8 +73,9 @@ export function addMetaDataToCall(callFn, input, resolverData, metaData, isRespo
73
73
  if (isResponseStream) {
74
74
  let isCancelled = false;
75
75
  const responseStreamWithCancel = withCancel(call, () => {
76
+ var _a;
76
77
  if (!isCancelled) {
77
- call.call?.cancelWithStatus(0, 'Cancelled by GraphQL Mesh');
78
+ (_a = call.call) === null || _a === void 0 ? void 0 : _a.cancelWithStatus(0, 'Cancelled by GraphQL Mesh');
78
79
  isCancelled = true;
79
80
  }
80
81
  });
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@graphql-mesh/grpc",
3
- "version": "1.0.0-alpha-20230523155104-df277a22b",
3
+ "version": "1.0.0-alpha-20230523160518-5443a1139",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@graphql-mesh/cross-helpers": "0.4.0-alpha-20230523155104-df277a22b",
7
- "@graphql-mesh/store": "1.0.0-alpha-20230523155104-df277a22b",
8
- "@graphql-mesh/types": "1.0.0-alpha-20230523155104-df277a22b",
9
- "@graphql-mesh/utils": "1.0.0-alpha-20230523155104-df277a22b",
6
+ "@graphql-mesh/cross-helpers": "0.4.0-alpha-20230523160518-5443a1139",
7
+ "@graphql-mesh/store": "1.0.0-alpha-20230523160518-5443a1139",
8
+ "@graphql-mesh/types": "1.0.0-alpha-20230523160518-5443a1139",
9
+ "@graphql-mesh/utils": "1.0.0-alpha-20230523160518-5443a1139",
10
10
  "@graphql-tools/utils": "^9.2.1",
11
11
  "graphql": "*",
12
12
  "tslib": "^2.4.0"
13
13
  },
14
14
  "dependencies": {
15
15
  "@ardatan/grpc-reflection-js": "0.0.2",
16
- "@graphql-mesh/string-interpolation": "0.5.0-alpha-20230523155104-df277a22b",
16
+ "@graphql-mesh/string-interpolation": "0.5.0-alpha-20230523160518-5443a1139",
17
17
  "@grpc/grpc-js": "^1.1.7",
18
18
  "@grpc/proto-loader": "0.7.7",
19
19
  "globby": "11.1.0",
@@ -30,9 +30,6 @@
30
30
  "directory": "packages/handlers/grpc"
31
31
  },
32
32
  "license": "MIT",
33
- "engines": {
34
- "node": ">=16.0.0"
35
- },
36
33
  "main": "cjs/index.js",
37
34
  "module": "esm/index.js",
38
35
  "typings": "typings/index.d.ts",