@ttoss/appsync-api 0.10.5 → 0.10.7

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/dist/cli.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
2
  "use strict";
3
+
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -8,20 +9,22 @@ var __getProtoOf = Object.getPrototypeOf;
8
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
10
  var __copyProps = (to, from, except, desc) => {
10
11
  if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
14
16
  }
15
17
  return to;
16
18
  };
17
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
- // If the importer is in node compatibility mode or this is not an ESM
19
- // file that has been converted to a CommonJS file using a Babel-
20
- // compatible transform (i.e. "__esModule" has not been set), then set
21
- // "default" to the CommonJS "module.exports" for node compatibility.
22
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
- mod
24
- ));
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
25
+ value: mod,
26
+ enumerable: true
27
+ }) : target, mod));
25
28
 
26
29
  // src/cli.ts
27
30
  var fs = __toESM(require("fs"));
@@ -31,6 +34,8 @@ var argv = (0, import_minimist.default)(process.argv.slice(2));
31
34
  if (argv._.includes("build-schema")) {
32
35
  const template = (0, import_cloudformation.findAndReadCloudFormationTemplate)({});
33
36
  const sdl = template.Metadata.Schema.Definition;
34
- fs.mkdirSync("schema", { recursive: true });
37
+ fs.mkdirSync("schema", {
38
+ recursive: true
39
+ });
35
40
  fs.writeFileSync("schema/schema.graphql", sdl);
36
- }
41
+ }
package/dist/esm/cli.js CHANGED
@@ -8,6 +8,8 @@ var argv = minimist(process.argv.slice(2));
8
8
  if (argv._.includes("build-schema")) {
9
9
  const template = findAndReadCloudFormationTemplate({});
10
10
  const sdl = template.Metadata.Schema.Definition;
11
- fs.mkdirSync("schema", { recursive: true });
11
+ fs.mkdirSync("schema", {
12
+ recursive: true
13
+ });
12
14
  fs.writeFileSync("schema/schema.graphql", sdl);
13
- }
15
+ }
package/dist/esm/index.js CHANGED
@@ -4,13 +4,11 @@
4
4
  import { graphql } from "graphql-compose";
5
5
 
6
6
  // ../../node_modules/tslib/tslib.es6.js
7
- var __assign = function() {
7
+ var __assign = function () {
8
8
  __assign = Object.assign || function __assign2(t) {
9
9
  for (var s, i = 1, n = arguments.length; i < n; i++) {
10
10
  s = arguments[i];
11
- for (var p in s)
12
- if (Object.prototype.hasOwnProperty.call(s, p))
13
- t[p] = s[p];
11
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
14
12
  }
15
13
  return t;
16
14
  };
@@ -29,20 +27,24 @@ function noCase(input, options) {
29
27
  if (options === void 0) {
30
28
  options = {};
31
29
  }
32
- var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
30
+ var _a = options.splitRegexp,
31
+ splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a,
32
+ _b = options.stripRegexp,
33
+ stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b,
34
+ _c = options.transform,
35
+ transform = _c === void 0 ? lowerCase : _c,
36
+ _d = options.delimiter,
37
+ delimiter = _d === void 0 ? " " : _d;
33
38
  var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
34
39
  var start = 0;
35
40
  var end = result.length;
36
- while (result.charAt(start) === "\0")
37
- start++;
38
- while (result.charAt(end - 1) === "\0")
39
- end--;
41
+ while (result.charAt(start) === "\0") start++;
42
+ while (result.charAt(end - 1) === "\0") end--;
40
43
  return result.slice(start, end).split("\0").map(transform).join(delimiter);
41
44
  }
42
45
  function replace(input, re, value) {
43
- if (re instanceof RegExp)
44
- return input.replace(re, value);
45
- return re.reduce(function(input2, re2) {
46
+ if (re instanceof RegExp) return input.replace(re, value);
47
+ return re.reduce(function (input2, re2) {
46
48
  return input2.replace(re2, value);
47
49
  }, input);
48
50
  }
@@ -60,32 +62,29 @@ function pascalCase(input, options) {
60
62
  if (options === void 0) {
61
63
  options = {};
62
64
  }
63
- return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options));
65
+ return noCase(input, __assign({
66
+ delimiter: "",
67
+ transform: pascalCaseTransform
68
+ }, options));
64
69
  }
65
70
 
66
71
  // ../carlin/src/deploy/lambdaLayer/getPackageLambdaLayerStackName.ts
67
72
  var lambdaLayerStackNamePrefix = `LambdaLayer`;
68
- var getPackageLambdaLayerStackName = (packageName) => {
69
- const [scopedName, version] = packageName.split("@").filter((part) => {
73
+ var getPackageLambdaLayerStackName = packageName => {
74
+ const [scopedName, version] = packageName.split("@").filter(part => {
70
75
  return !!part;
71
76
  });
72
- return [
73
- lambdaLayerStackNamePrefix,
74
- pascalCase(scopedName),
75
- version.replace(/[^0-9.]/g, "").replace(/\./g, "-")
76
- ].join("-");
77
+ return [lambdaLayerStackNamePrefix, pascalCase(scopedName), version.replace(/[^0-9.]/g, "").replace(/\./g, "-")].join("-");
77
78
  };
78
79
 
79
80
  // package.json
80
81
  var package_default = {
81
82
  name: "@ttoss/appsync-api",
82
- version: "0.10.5",
83
+ version: "0.10.7",
83
84
  description: "A library for building GraphQL APIs for AWS AppSync.",
84
85
  license: "UNLICENSED",
85
86
  author: "ttoss",
86
- contributors: [
87
- "Pedro Arantes <pedro@arantespp.com> (https://arantespp.com)"
88
- ],
87
+ contributors: ["Pedro Arantes <pedro@arantespp.com> (https://arantespp.com)"],
89
88
  exports: {
90
89
  ".": {
91
90
  import: "./dist/esm/index.js",
@@ -101,10 +100,7 @@ var package_default = {
101
100
  bin: {
102
101
  "ttoss-appsync-api": "./bin/cli.js"
103
102
  },
104
- files: [
105
- "dist",
106
- "src"
107
- ],
103
+ files: ["dist", "src"],
108
104
  scripts: {
109
105
  build: "tsup",
110
106
  test: "jest"
@@ -112,7 +108,7 @@ var package_default = {
112
108
  sideEffects: false,
113
109
  typings: "dist/index.d.ts",
114
110
  dependencies: {
115
- "@ttoss/cloudformation": "^0.6.4",
111
+ "@ttoss/cloudformation": "^0.6.6",
116
112
  express: "^4.18.2",
117
113
  "graphql-compose-connection": "^8.2.1",
118
114
  "graphql-helix": "^1.13.0",
@@ -123,30 +119,21 @@ var package_default = {
123
119
  "graphql-compose": "^9.0.10"
124
120
  },
125
121
  devDependencies: {
126
- "@ttoss/config": "^1.29.1",
127
- "@ttoss/relay-amplify": "^0.4.2",
122
+ "@ttoss/config": "^1.29.2",
123
+ "@ttoss/relay-amplify": "^0.4.3",
128
124
  "@types/aws-lambda": "^8.10.111",
129
- carlin: "^1.26.2",
125
+ carlin: "^1.26.4",
130
126
  graphql: "^16.6.0",
131
127
  "graphql-compose": "^9.0.10"
132
128
  },
133
- keywords: [
134
- "api",
135
- "appsync",
136
- "aws",
137
- "graphql"
138
- ],
129
+ keywords: ["api", "appsync", "aws", "graphql"],
139
130
  publishConfig: {
140
131
  access: "public"
141
132
  },
142
133
  typesVersions: {
143
134
  "*": {
144
- ".": [
145
- "./dist/index.d.ts"
146
- ],
147
- server: [
148
- "./dist/server.d.ts"
149
- ]
135
+ ".": ["./dist/index.d.ts"],
136
+ server: ["./dist/server.d.ts"]
150
137
  }
151
138
  }
152
139
  };
@@ -190,15 +177,13 @@ var createApiTemplate = ({
190
177
  });
191
178
  }).filter(Boolean);
192
179
  const getGraphQLComposeDependenciesLambdaLayers = () => {
193
- const { peerDependencies } = package_default;
194
- const lambdaLayerStackNames = Object.entries(peerDependencies).map(
195
- ([dependencyName, dependencyVersion]) => {
196
- return getPackageLambdaLayerStackName(
197
- [dependencyName, dependencyVersion].join("@")
198
- );
199
- }
200
- );
201
- return lambdaLayerStackNames.map((lambdaLayerStackName) => {
180
+ const {
181
+ peerDependencies
182
+ } = package_default;
183
+ const lambdaLayerStackNames = Object.entries(peerDependencies).map(([dependencyName, dependencyVersion]) => {
184
+ return getPackageLambdaLayerStackName([dependencyName, dependencyVersion].join("@"));
185
+ });
186
+ return lambdaLayerStackNames.map(lambdaLayerStackName => {
202
187
  return {
203
188
  "Fn::ImportValue": lambdaLayerStackName
204
189
  };
@@ -236,17 +221,18 @@ var createApiTemplate = ({
236
221
  Properties: {
237
222
  AuthenticationType: authenticationType,
238
223
  Name: {
239
- "Fn::Join": [
240
- ":",
241
- [{ Ref: "AWS::StackName" }, AppSyncGraphQLApiLogicalId]
242
- ]
224
+ "Fn::Join": [":", [{
225
+ Ref: "AWS::StackName"
226
+ }, AppSyncGraphQLApiLogicalId]]
243
227
  }
244
228
  }
245
229
  },
246
230
  [AppSyncGraphQLSchemaLogicalId]: {
247
231
  Type: "AWS::AppSync::GraphQLSchema",
248
232
  Properties: {
249
- ApiId: { "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"] },
233
+ ApiId: {
234
+ "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"]
235
+ },
250
236
  Definition: sdlWithoutComments
251
237
  }
252
238
  },
@@ -254,9 +240,15 @@ var createApiTemplate = ({
254
240
  Type: "AWS::Lambda::Function",
255
241
  Properties: {
256
242
  Code: {
257
- S3Bucket: { Ref: "LambdaS3Bucket" },
258
- S3Key: { Ref: "LambdaS3Key" },
259
- S3ObjectVersion: { Ref: "LambdaS3ObjectVersion" }
243
+ S3Bucket: {
244
+ Ref: "LambdaS3Bucket"
245
+ },
246
+ S3Key: {
247
+ Ref: "LambdaS3Key"
248
+ },
249
+ S3ObjectVersion: {
250
+ Ref: "LambdaS3ObjectVersion"
251
+ }
260
252
  },
261
253
  Handler: "index.handler",
262
254
  Layers: getGraphQLComposeDependenciesLambdaLayers(),
@@ -273,7 +265,9 @@ var createApiTemplate = ({
273
265
  [AppSyncLambdaFunctionAppSyncDataSourceLogicalId]: {
274
266
  Type: "AWS::AppSync::DataSource",
275
267
  Properties: {
276
- ApiId: { "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"] },
268
+ ApiId: {
269
+ "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"]
270
+ },
277
271
  LambdaConfig: {
278
272
  LambdaFunctionArn: {
279
273
  "Fn::GetAtt": [AppSyncLambdaFunctionLogicalId, "Arn"]
@@ -289,10 +283,9 @@ var createApiTemplate = ({
289
283
  AppSyncApiGraphQLUrl: {
290
284
  Export: {
291
285
  Name: {
292
- "Fn::Join": [
293
- ":",
294
- [{ Ref: "AWS::StackName" }, "AppSyncApiGraphQLUrl"]
295
- ]
286
+ "Fn::Join": [":", [{
287
+ Ref: "AWS::StackName"
288
+ }, "AppSyncApiGraphQLUrl"]]
296
289
  }
297
290
  },
298
291
  Value: {
@@ -302,7 +295,9 @@ var createApiTemplate = ({
302
295
  AppSyncApiArn: {
303
296
  Export: {
304
297
  Name: {
305
- "Fn::Join": [":", [{ Ref: "AWS::StackName" }, "AppSyncApiArn"]]
298
+ "Fn::Join": [":", [{
299
+ Ref: "AWS::StackName"
300
+ }, "AppSyncApiArn"]]
306
301
  }
307
302
  },
308
303
  Value: {
@@ -311,19 +306,21 @@ var createApiTemplate = ({
311
306
  }
312
307
  }
313
308
  };
314
- resolveMethodsEntries.forEach(({ fieldName, typeName }) => {
309
+ resolveMethodsEntries.forEach(({
310
+ fieldName,
311
+ typeName
312
+ }) => {
315
313
  template.Resources[`${fieldName}${typeName}AppSyncResolver`] = {
316
314
  Type: "AWS::AppSync::Resolver",
317
315
  DependsOn: AppSyncGraphQLSchemaLogicalId,
318
316
  Properties: {
319
- ApiId: { "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"] },
317
+ ApiId: {
318
+ "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"]
319
+ },
320
320
  FieldName: fieldName,
321
321
  TypeName: typeName,
322
322
  DataSourceName: {
323
- "Fn::GetAtt": [
324
- AppSyncLambdaFunctionAppSyncDataSourceLogicalId,
325
- "Name"
326
- ]
323
+ "Fn::GetAtt": [AppSyncLambdaFunctionAppSyncDataSourceLogicalId, "Name"]
327
324
  }
328
325
  }
329
326
  };
@@ -331,7 +328,7 @@ var createApiTemplate = ({
331
328
  const apiKey = additionalAuthenticationProviders?.includes("API_KEY") || authenticationType === "API_KEY";
332
329
  const cognitoUserPoolAuth = additionalAuthenticationProviders?.includes("AMAZON_COGNITO_USER_POOLS") || authenticationType === "AMAZON_COGNITO_USER_POOLS";
333
330
  if (additionalAuthenticationProviders) {
334
- template.Resources[AppSyncGraphQLApiLogicalId].Properties.AdditionalAuthenticationProviders = additionalAuthenticationProviders?.map((provider) => {
331
+ template.Resources[AppSyncGraphQLApiLogicalId].Properties.AdditionalAuthenticationProviders = additionalAuthenticationProviders?.map(provider => {
335
332
  return {
336
333
  AuthenticationType: provider
337
334
  };
@@ -341,7 +338,9 @@ var createApiTemplate = ({
341
338
  template.Resources[AppSyncGraphQLApiKeyLogicalId] = {
342
339
  Type: "AWS::AppSync::ApiKey",
343
340
  Properties: {
344
- ApiId: { "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"] }
341
+ ApiId: {
342
+ "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"]
343
+ }
345
344
  }
346
345
  };
347
346
  if (!template.Outputs) {
@@ -355,9 +354,7 @@ var createApiTemplate = ({
355
354
  }
356
355
  if (cognitoUserPoolAuth) {
357
356
  if (!userPoolConfig) {
358
- throw new Error(
359
- "userPoolConfig is required when using AMAZON_COGNITO_USER_POOLS authentication."
360
- );
357
+ throw new Error("userPoolConfig is required when using AMAZON_COGNITO_USER_POOLS authentication.");
361
358
  }
362
359
  template.Resources[AppSyncGraphQLApiLogicalId].Properties.UserPoolConfig = {
363
360
  AppIdClientRegex: userPoolConfig.appIdClientRegex,
@@ -375,7 +372,7 @@ var createApiTemplate = ({
375
372
  };
376
373
 
377
374
  // ../relay-amplify/src/encodeCredentials.ts
378
- var decodeCredentials = (credentials) => {
375
+ var decodeCredentials = credentials => {
379
376
  return JSON.parse(Buffer.from(credentials, "base64").toString("utf8"));
380
377
  };
381
378
 
@@ -384,8 +381,16 @@ var createAppSyncResolverHandler = ({
384
381
  schemaComposer: schemaComposer2
385
382
  }) => {
386
383
  return async (event, context) => {
387
- const { info, arguments: args, source, request } = event;
388
- const { parentTypeName, fieldName } = info;
384
+ const {
385
+ info,
386
+ arguments: args,
387
+ source,
388
+ request
389
+ } = event;
390
+ const {
391
+ parentTypeName,
392
+ fieldName
393
+ } = info;
389
394
  const headers = request?.headers || {};
390
395
  const credentials = (() => {
391
396
  const headersCredentials = headers?.["x-credentials"];
@@ -396,12 +401,12 @@ var createAppSyncResolverHandler = ({
396
401
  })();
397
402
  const resolveMethods = schemaComposer2.getResolveMethods();
398
403
  const resolver = resolveMethods[parentTypeName][fieldName];
399
- return resolver(
400
- source,
401
- args,
402
- { ...context, identity: event.identity, credentials, headers },
403
- info
404
- );
404
+ return resolver(source, args, {
405
+ ...context,
406
+ identity: event.identity,
407
+ credentials,
408
+ headers
409
+ }, info);
405
410
  };
406
411
  };
407
412
 
@@ -409,24 +414,25 @@ var createAppSyncResolverHandler = ({
409
414
  import { ObjectTypeComposer } from "graphql-compose";
410
415
 
411
416
  // src/composeWithRelay/nodeFieldConfig.ts
412
- import {
413
- getProjectionFromAST
414
- } from "graphql-compose";
417
+ import { getProjectionFromAST } from "graphql-compose";
415
418
 
416
419
  // src/composeWithRelay/globalId.ts
417
- var base64 = (i) => {
420
+ var base64 = i => {
418
421
  return Buffer.from(i, "ascii").toString("base64");
419
422
  };
420
- var unbase64 = (i) => {
423
+ var unbase64 = i => {
421
424
  return Buffer.from(i, "base64").toString("ascii");
422
425
  };
423
426
  var toGlobalId = (type, id) => {
424
427
  return base64([type, id].join(":"));
425
428
  };
426
- var fromGlobalId = (globalId) => {
429
+ var fromGlobalId = globalId => {
427
430
  const unbasedGlobalId = unbase64(globalId);
428
431
  const [type, id] = unbasedGlobalId.split(":");
429
- return { type, id };
432
+ return {
433
+ type,
434
+ id
435
+ };
430
436
  };
431
437
 
432
438
  // src/composeWithRelay/nodeFieldConfig.ts
@@ -444,11 +450,16 @@ var getNodeFieldConfig = (typeMapForRelayNode, nodeInterface) => {
444
450
  if (!args.id || !(typeof args.id === "string")) {
445
451
  return null;
446
452
  }
447
- const { type } = fromGlobalId(args.id);
453
+ const {
454
+ type
455
+ } = fromGlobalId(args.id);
448
456
  if (!typeMapForRelayNode[type]) {
449
457
  return null;
450
458
  }
451
- const { tc, resolver: findById } = typeMapForRelayNode[type];
459
+ const {
460
+ tc,
461
+ resolver: findById
462
+ } = typeMapForRelayNode[type];
452
463
  if (findById && findById.resolve && tc) {
453
464
  const graphqlType = tc.getType();
454
465
  let projection;
@@ -463,14 +474,15 @@ var getNodeFieldConfig = (typeMapForRelayNode, nodeInterface) => {
463
474
  const idArgName = Object.keys(findById.args)[0];
464
475
  return findById.resolve({
465
476
  source,
466
- args: { [idArgName]: args.id },
477
+ args: {
478
+ [idArgName]: args.id
479
+ },
467
480
  // eg. mongoose has _id fieldname, so should map
468
481
  context,
469
482
  info,
470
483
  projection
471
- }).then((res) => {
472
- if (!res)
473
- return res;
484
+ }).then(res => {
485
+ if (!res) return res;
474
486
  res.__nodeType = graphqlType;
475
487
  return res;
476
488
  });
@@ -491,12 +503,12 @@ var NodeTC = InterfaceTypeComposer.createTemp({
491
503
  description: "The globally unique ID among all types."
492
504
  }
493
505
  },
494
- resolveType: (payload) => {
506
+ resolveType: payload => {
495
507
  return payload.__nodeType.name ? payload.__nodeType.name : null;
496
508
  }
497
509
  });
498
510
  var NodeInterface = NodeTC.getType();
499
- var getNodeInterface = (sc) => {
511
+ var getNodeInterface = sc => {
500
512
  if (sc.hasInstance("Node", InterfaceTypeComposer)) {
501
513
  return sc.get("Node");
502
514
  }
@@ -506,17 +518,12 @@ var getNodeInterface = (sc) => {
506
518
 
507
519
  // src/composeWithRelay/composeWithRelay.ts
508
520
  var TypeMapForRelayNode = {};
509
- var composeWithRelay = (tc) => {
521
+ var composeWithRelay = tc => {
510
522
  if (!(tc instanceof ObjectTypeComposer)) {
511
- throw new Error(
512
- "You should provide ObjectTypeComposer instance to composeWithRelay method"
513
- );
523
+ throw new Error("You should provide ObjectTypeComposer instance to composeWithRelay method");
514
524
  }
515
525
  const nodeInterface = getNodeInterface(tc.schemaComposer);
516
- const nodeFieldConfig = getNodeFieldConfig(
517
- TypeMapForRelayNode,
518
- nodeInterface
519
- );
526
+ const nodeFieldConfig = getNodeFieldConfig(TypeMapForRelayNode, nodeInterface);
520
527
  if (tc.getTypeName() === "Query" || tc.getTypeName() === "RootQuery") {
521
528
  tc.setField("node", nodeFieldConfig);
522
529
  return tc;
@@ -525,15 +532,11 @@ var composeWithRelay = (tc) => {
525
532
  return tc;
526
533
  }
527
534
  if (!tc.hasRecordIdFn()) {
528
- throw new Error(
529
- `ObjectTypeComposer(${tc.getTypeName()}) should have recordIdFn. This function returns ID from provided object.`
530
- );
535
+ throw new Error(`ObjectTypeComposer(${tc.getTypeName()}) should have recordIdFn. This function returns ID from provided object.`);
531
536
  }
532
537
  const findById = tc.getResolver("findById");
533
538
  if (!findById) {
534
- throw new Error(
535
- `ObjectTypeComposer(${tc.getTypeName()}) provided to composeWithRelay should have findById resolver.`
536
- );
539
+ throw new Error(`ObjectTypeComposer(${tc.getTypeName()}) provided to composeWithRelay should have findById resolver.`);
537
540
  }
538
541
  TypeMapForRelayNode[tc.getTypeName()] = {
539
542
  resolver: findById,
@@ -543,7 +546,7 @@ var composeWithRelay = (tc) => {
543
546
  id: {
544
547
  type: "ID!",
545
548
  description: "The globally unique ID among all types",
546
- resolve: (source) => {
549
+ resolve: source => {
547
550
  return toGlobalId(tc.getTypeName(), tc.getRecordId(source));
548
551
  }
549
552
  }
@@ -558,11 +561,4 @@ composeWithRelay(schemaComposer.Query);
558
561
 
559
562
  // src/index.ts
560
563
  import { default as default2 } from "graphql-compose-connection";
561
- export {
562
- default2 as composeWithConnection,
563
- composeWithRelay,
564
- createApiTemplate,
565
- createAppSyncResolverHandler,
566
- fromGlobalId,
567
- toGlobalId
568
- };
564
+ export { default2 as composeWithConnection, composeWithRelay, createApiTemplate, createAppSyncResolverHandler, fromGlobalId, toGlobalId };
@@ -1,13 +1,7 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
2
 
3
3
  // src/server.ts
4
- import {
5
- getGraphQLParameters,
6
- processRequest,
7
- renderGraphiQL,
8
- sendResult,
9
- shouldRenderGraphiQL
10
- } from "graphql-helix";
4
+ import { getGraphQLParameters, processRequest, renderGraphiQL, sendResult, shouldRenderGraphiQL } from "graphql-helix";
11
5
  import express from "express";
12
6
  var createServer = ({
13
7
  schemaComposer
@@ -25,7 +19,11 @@ var createServer = ({
25
19
  res.send(renderGraphiQL());
26
20
  return;
27
21
  }
28
- const { operationName, query, variables } = getGraphQLParameters(request);
22
+ const {
23
+ operationName,
24
+ query,
25
+ variables
26
+ } = getGraphQLParameters(request);
29
27
  const result = await processRequest({
30
28
  operationName,
31
29
  query,
@@ -37,6 +35,4 @@ var createServer = ({
37
35
  });
38
36
  return server;
39
37
  };
40
- export {
41
- createServer
42
- };
38
+ export { createServer };
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
2
  "use strict";
3
+
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -7,26 +8,32 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
7
8
  var __getProtoOf = Object.getPrototypeOf;
8
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
10
  var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
12
15
  };
13
16
  var __copyProps = (to, from, except, desc) => {
14
17
  if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
+ get: () => from[key],
20
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
+ });
18
22
  }
19
23
  return to;
20
24
  };
21
25
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
26
+ // If the importer is in node compatibility mode or this is not an ESM
27
+ // file that has been converted to a CommonJS file using a Babel-
28
+ // compatible transform (i.e. "__esModule" has not been set), then set
29
+ // "default" to the CommonJS "module.exports" for node compatibility.
30
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
31
+ value: mod,
32
+ enumerable: true
33
+ }) : target, mod));
34
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
35
+ value: true
36
+ }), mod);
30
37
 
31
38
  // src/index.ts
32
39
  var src_exports = {};
@@ -44,13 +51,11 @@ module.exports = __toCommonJS(src_exports);
44
51
  var import_graphql_compose = require("graphql-compose");
45
52
 
46
53
  // ../../node_modules/tslib/tslib.es6.js
47
- var __assign = function() {
54
+ var __assign = function () {
48
55
  __assign = Object.assign || function __assign2(t) {
49
56
  for (var s, i = 1, n = arguments.length; i < n; i++) {
50
57
  s = arguments[i];
51
- for (var p in s)
52
- if (Object.prototype.hasOwnProperty.call(s, p))
53
- t[p] = s[p];
58
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
54
59
  }
55
60
  return t;
56
61
  };
@@ -69,20 +74,24 @@ function noCase(input, options) {
69
74
  if (options === void 0) {
70
75
  options = {};
71
76
  }
72
- var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
77
+ var _a = options.splitRegexp,
78
+ splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a,
79
+ _b = options.stripRegexp,
80
+ stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b,
81
+ _c = options.transform,
82
+ transform = _c === void 0 ? lowerCase : _c,
83
+ _d = options.delimiter,
84
+ delimiter = _d === void 0 ? " " : _d;
73
85
  var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
74
86
  var start = 0;
75
87
  var end = result.length;
76
- while (result.charAt(start) === "\0")
77
- start++;
78
- while (result.charAt(end - 1) === "\0")
79
- end--;
88
+ while (result.charAt(start) === "\0") start++;
89
+ while (result.charAt(end - 1) === "\0") end--;
80
90
  return result.slice(start, end).split("\0").map(transform).join(delimiter);
81
91
  }
82
92
  function replace(input, re, value) {
83
- if (re instanceof RegExp)
84
- return input.replace(re, value);
85
- return re.reduce(function(input2, re2) {
93
+ if (re instanceof RegExp) return input.replace(re, value);
94
+ return re.reduce(function (input2, re2) {
86
95
  return input2.replace(re2, value);
87
96
  }, input);
88
97
  }
@@ -100,32 +109,29 @@ function pascalCase(input, options) {
100
109
  if (options === void 0) {
101
110
  options = {};
102
111
  }
103
- return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options));
112
+ return noCase(input, __assign({
113
+ delimiter: "",
114
+ transform: pascalCaseTransform
115
+ }, options));
104
116
  }
105
117
 
106
118
  // ../carlin/src/deploy/lambdaLayer/getPackageLambdaLayerStackName.ts
107
119
  var lambdaLayerStackNamePrefix = `LambdaLayer`;
108
- var getPackageLambdaLayerStackName = (packageName) => {
109
- const [scopedName, version] = packageName.split("@").filter((part) => {
120
+ var getPackageLambdaLayerStackName = packageName => {
121
+ const [scopedName, version] = packageName.split("@").filter(part => {
110
122
  return !!part;
111
123
  });
112
- return [
113
- lambdaLayerStackNamePrefix,
114
- pascalCase(scopedName),
115
- version.replace(/[^0-9.]/g, "").replace(/\./g, "-")
116
- ].join("-");
124
+ return [lambdaLayerStackNamePrefix, pascalCase(scopedName), version.replace(/[^0-9.]/g, "").replace(/\./g, "-")].join("-");
117
125
  };
118
126
 
119
127
  // package.json
120
128
  var package_default = {
121
129
  name: "@ttoss/appsync-api",
122
- version: "0.10.5",
130
+ version: "0.10.7",
123
131
  description: "A library for building GraphQL APIs for AWS AppSync.",
124
132
  license: "UNLICENSED",
125
133
  author: "ttoss",
126
- contributors: [
127
- "Pedro Arantes <pedro@arantespp.com> (https://arantespp.com)"
128
- ],
134
+ contributors: ["Pedro Arantes <pedro@arantespp.com> (https://arantespp.com)"],
129
135
  exports: {
130
136
  ".": {
131
137
  import: "./dist/esm/index.js",
@@ -141,10 +147,7 @@ var package_default = {
141
147
  bin: {
142
148
  "ttoss-appsync-api": "./bin/cli.js"
143
149
  },
144
- files: [
145
- "dist",
146
- "src"
147
- ],
150
+ files: ["dist", "src"],
148
151
  scripts: {
149
152
  build: "tsup",
150
153
  test: "jest"
@@ -152,7 +155,7 @@ var package_default = {
152
155
  sideEffects: false,
153
156
  typings: "dist/index.d.ts",
154
157
  dependencies: {
155
- "@ttoss/cloudformation": "^0.6.4",
158
+ "@ttoss/cloudformation": "^0.6.6",
156
159
  express: "^4.18.2",
157
160
  "graphql-compose-connection": "^8.2.1",
158
161
  "graphql-helix": "^1.13.0",
@@ -163,30 +166,21 @@ var package_default = {
163
166
  "graphql-compose": "^9.0.10"
164
167
  },
165
168
  devDependencies: {
166
- "@ttoss/config": "^1.29.1",
167
- "@ttoss/relay-amplify": "^0.4.2",
169
+ "@ttoss/config": "^1.29.2",
170
+ "@ttoss/relay-amplify": "^0.4.3",
168
171
  "@types/aws-lambda": "^8.10.111",
169
- carlin: "^1.26.2",
172
+ carlin: "^1.26.4",
170
173
  graphql: "^16.6.0",
171
174
  "graphql-compose": "^9.0.10"
172
175
  },
173
- keywords: [
174
- "api",
175
- "appsync",
176
- "aws",
177
- "graphql"
178
- ],
176
+ keywords: ["api", "appsync", "aws", "graphql"],
179
177
  publishConfig: {
180
178
  access: "public"
181
179
  },
182
180
  typesVersions: {
183
181
  "*": {
184
- ".": [
185
- "./dist/index.d.ts"
186
- ],
187
- server: [
188
- "./dist/server.d.ts"
189
- ]
182
+ ".": ["./dist/index.d.ts"],
183
+ server: ["./dist/server.d.ts"]
190
184
  }
191
185
  }
192
186
  };
@@ -230,15 +224,13 @@ var createApiTemplate = ({
230
224
  });
231
225
  }).filter(Boolean);
232
226
  const getGraphQLComposeDependenciesLambdaLayers = () => {
233
- const { peerDependencies } = package_default;
234
- const lambdaLayerStackNames = Object.entries(peerDependencies).map(
235
- ([dependencyName, dependencyVersion]) => {
236
- return getPackageLambdaLayerStackName(
237
- [dependencyName, dependencyVersion].join("@")
238
- );
239
- }
240
- );
241
- return lambdaLayerStackNames.map((lambdaLayerStackName) => {
227
+ const {
228
+ peerDependencies
229
+ } = package_default;
230
+ const lambdaLayerStackNames = Object.entries(peerDependencies).map(([dependencyName, dependencyVersion]) => {
231
+ return getPackageLambdaLayerStackName([dependencyName, dependencyVersion].join("@"));
232
+ });
233
+ return lambdaLayerStackNames.map(lambdaLayerStackName => {
242
234
  return {
243
235
  "Fn::ImportValue": lambdaLayerStackName
244
236
  };
@@ -276,17 +268,18 @@ var createApiTemplate = ({
276
268
  Properties: {
277
269
  AuthenticationType: authenticationType,
278
270
  Name: {
279
- "Fn::Join": [
280
- ":",
281
- [{ Ref: "AWS::StackName" }, AppSyncGraphQLApiLogicalId]
282
- ]
271
+ "Fn::Join": [":", [{
272
+ Ref: "AWS::StackName"
273
+ }, AppSyncGraphQLApiLogicalId]]
283
274
  }
284
275
  }
285
276
  },
286
277
  [AppSyncGraphQLSchemaLogicalId]: {
287
278
  Type: "AWS::AppSync::GraphQLSchema",
288
279
  Properties: {
289
- ApiId: { "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"] },
280
+ ApiId: {
281
+ "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"]
282
+ },
290
283
  Definition: sdlWithoutComments
291
284
  }
292
285
  },
@@ -294,9 +287,15 @@ var createApiTemplate = ({
294
287
  Type: "AWS::Lambda::Function",
295
288
  Properties: {
296
289
  Code: {
297
- S3Bucket: { Ref: "LambdaS3Bucket" },
298
- S3Key: { Ref: "LambdaS3Key" },
299
- S3ObjectVersion: { Ref: "LambdaS3ObjectVersion" }
290
+ S3Bucket: {
291
+ Ref: "LambdaS3Bucket"
292
+ },
293
+ S3Key: {
294
+ Ref: "LambdaS3Key"
295
+ },
296
+ S3ObjectVersion: {
297
+ Ref: "LambdaS3ObjectVersion"
298
+ }
300
299
  },
301
300
  Handler: "index.handler",
302
301
  Layers: getGraphQLComposeDependenciesLambdaLayers(),
@@ -313,7 +312,9 @@ var createApiTemplate = ({
313
312
  [AppSyncLambdaFunctionAppSyncDataSourceLogicalId]: {
314
313
  Type: "AWS::AppSync::DataSource",
315
314
  Properties: {
316
- ApiId: { "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"] },
315
+ ApiId: {
316
+ "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"]
317
+ },
317
318
  LambdaConfig: {
318
319
  LambdaFunctionArn: {
319
320
  "Fn::GetAtt": [AppSyncLambdaFunctionLogicalId, "Arn"]
@@ -329,10 +330,9 @@ var createApiTemplate = ({
329
330
  AppSyncApiGraphQLUrl: {
330
331
  Export: {
331
332
  Name: {
332
- "Fn::Join": [
333
- ":",
334
- [{ Ref: "AWS::StackName" }, "AppSyncApiGraphQLUrl"]
335
- ]
333
+ "Fn::Join": [":", [{
334
+ Ref: "AWS::StackName"
335
+ }, "AppSyncApiGraphQLUrl"]]
336
336
  }
337
337
  },
338
338
  Value: {
@@ -342,7 +342,9 @@ var createApiTemplate = ({
342
342
  AppSyncApiArn: {
343
343
  Export: {
344
344
  Name: {
345
- "Fn::Join": [":", [{ Ref: "AWS::StackName" }, "AppSyncApiArn"]]
345
+ "Fn::Join": [":", [{
346
+ Ref: "AWS::StackName"
347
+ }, "AppSyncApiArn"]]
346
348
  }
347
349
  },
348
350
  Value: {
@@ -351,19 +353,21 @@ var createApiTemplate = ({
351
353
  }
352
354
  }
353
355
  };
354
- resolveMethodsEntries.forEach(({ fieldName, typeName }) => {
356
+ resolveMethodsEntries.forEach(({
357
+ fieldName,
358
+ typeName
359
+ }) => {
355
360
  template.Resources[`${fieldName}${typeName}AppSyncResolver`] = {
356
361
  Type: "AWS::AppSync::Resolver",
357
362
  DependsOn: AppSyncGraphQLSchemaLogicalId,
358
363
  Properties: {
359
- ApiId: { "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"] },
364
+ ApiId: {
365
+ "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"]
366
+ },
360
367
  FieldName: fieldName,
361
368
  TypeName: typeName,
362
369
  DataSourceName: {
363
- "Fn::GetAtt": [
364
- AppSyncLambdaFunctionAppSyncDataSourceLogicalId,
365
- "Name"
366
- ]
370
+ "Fn::GetAtt": [AppSyncLambdaFunctionAppSyncDataSourceLogicalId, "Name"]
367
371
  }
368
372
  }
369
373
  };
@@ -371,7 +375,7 @@ var createApiTemplate = ({
371
375
  const apiKey = additionalAuthenticationProviders?.includes("API_KEY") || authenticationType === "API_KEY";
372
376
  const cognitoUserPoolAuth = additionalAuthenticationProviders?.includes("AMAZON_COGNITO_USER_POOLS") || authenticationType === "AMAZON_COGNITO_USER_POOLS";
373
377
  if (additionalAuthenticationProviders) {
374
- template.Resources[AppSyncGraphQLApiLogicalId].Properties.AdditionalAuthenticationProviders = additionalAuthenticationProviders?.map((provider) => {
378
+ template.Resources[AppSyncGraphQLApiLogicalId].Properties.AdditionalAuthenticationProviders = additionalAuthenticationProviders?.map(provider => {
375
379
  return {
376
380
  AuthenticationType: provider
377
381
  };
@@ -381,7 +385,9 @@ var createApiTemplate = ({
381
385
  template.Resources[AppSyncGraphQLApiKeyLogicalId] = {
382
386
  Type: "AWS::AppSync::ApiKey",
383
387
  Properties: {
384
- ApiId: { "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"] }
388
+ ApiId: {
389
+ "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"]
390
+ }
385
391
  }
386
392
  };
387
393
  if (!template.Outputs) {
@@ -395,9 +401,7 @@ var createApiTemplate = ({
395
401
  }
396
402
  if (cognitoUserPoolAuth) {
397
403
  if (!userPoolConfig) {
398
- throw new Error(
399
- "userPoolConfig is required when using AMAZON_COGNITO_USER_POOLS authentication."
400
- );
404
+ throw new Error("userPoolConfig is required when using AMAZON_COGNITO_USER_POOLS authentication.");
401
405
  }
402
406
  template.Resources[AppSyncGraphQLApiLogicalId].Properties.UserPoolConfig = {
403
407
  AppIdClientRegex: userPoolConfig.appIdClientRegex,
@@ -415,7 +419,7 @@ var createApiTemplate = ({
415
419
  };
416
420
 
417
421
  // ../relay-amplify/src/encodeCredentials.ts
418
- var decodeCredentials = (credentials) => {
422
+ var decodeCredentials = credentials => {
419
423
  return JSON.parse(Buffer.from(credentials, "base64").toString("utf8"));
420
424
  };
421
425
 
@@ -424,8 +428,16 @@ var createAppSyncResolverHandler = ({
424
428
  schemaComposer: schemaComposer2
425
429
  }) => {
426
430
  return async (event, context) => {
427
- const { info, arguments: args, source, request } = event;
428
- const { parentTypeName, fieldName } = info;
431
+ const {
432
+ info,
433
+ arguments: args,
434
+ source,
435
+ request
436
+ } = event;
437
+ const {
438
+ parentTypeName,
439
+ fieldName
440
+ } = info;
429
441
  const headers = request?.headers || {};
430
442
  const credentials = (() => {
431
443
  const headersCredentials = headers?.["x-credentials"];
@@ -436,12 +448,12 @@ var createAppSyncResolverHandler = ({
436
448
  })();
437
449
  const resolveMethods = schemaComposer2.getResolveMethods();
438
450
  const resolver = resolveMethods[parentTypeName][fieldName];
439
- return resolver(
440
- source,
441
- args,
442
- { ...context, identity: event.identity, credentials, headers },
443
- info
444
- );
451
+ return resolver(source, args, {
452
+ ...context,
453
+ identity: event.identity,
454
+ credentials,
455
+ headers
456
+ }, info);
445
457
  };
446
458
  };
447
459
 
@@ -452,19 +464,22 @@ var import_graphql_compose4 = require("graphql-compose");
452
464
  var import_graphql_compose2 = require("graphql-compose");
453
465
 
454
466
  // src/composeWithRelay/globalId.ts
455
- var base64 = (i) => {
467
+ var base64 = i => {
456
468
  return Buffer.from(i, "ascii").toString("base64");
457
469
  };
458
- var unbase64 = (i) => {
470
+ var unbase64 = i => {
459
471
  return Buffer.from(i, "base64").toString("ascii");
460
472
  };
461
473
  var toGlobalId = (type, id) => {
462
474
  return base64([type, id].join(":"));
463
475
  };
464
- var fromGlobalId = (globalId) => {
476
+ var fromGlobalId = globalId => {
465
477
  const unbasedGlobalId = unbase64(globalId);
466
478
  const [type, id] = unbasedGlobalId.split(":");
467
- return { type, id };
479
+ return {
480
+ type,
481
+ id
482
+ };
468
483
  };
469
484
 
470
485
  // src/composeWithRelay/nodeFieldConfig.ts
@@ -482,11 +497,16 @@ var getNodeFieldConfig = (typeMapForRelayNode, nodeInterface) => {
482
497
  if (!args.id || !(typeof args.id === "string")) {
483
498
  return null;
484
499
  }
485
- const { type } = fromGlobalId(args.id);
500
+ const {
501
+ type
502
+ } = fromGlobalId(args.id);
486
503
  if (!typeMapForRelayNode[type]) {
487
504
  return null;
488
505
  }
489
- const { tc, resolver: findById } = typeMapForRelayNode[type];
506
+ const {
507
+ tc,
508
+ resolver: findById
509
+ } = typeMapForRelayNode[type];
490
510
  if (findById && findById.resolve && tc) {
491
511
  const graphqlType = tc.getType();
492
512
  let projection;
@@ -501,14 +521,15 @@ var getNodeFieldConfig = (typeMapForRelayNode, nodeInterface) => {
501
521
  const idArgName = Object.keys(findById.args)[0];
502
522
  return findById.resolve({
503
523
  source,
504
- args: { [idArgName]: args.id },
524
+ args: {
525
+ [idArgName]: args.id
526
+ },
505
527
  // eg. mongoose has _id fieldname, so should map
506
528
  context,
507
529
  info,
508
530
  projection
509
- }).then((res) => {
510
- if (!res)
511
- return res;
531
+ }).then(res => {
532
+ if (!res) return res;
512
533
  res.__nodeType = graphqlType;
513
534
  return res;
514
535
  });
@@ -529,12 +550,12 @@ var NodeTC = import_graphql_compose3.InterfaceTypeComposer.createTemp({
529
550
  description: "The globally unique ID among all types."
530
551
  }
531
552
  },
532
- resolveType: (payload) => {
553
+ resolveType: payload => {
533
554
  return payload.__nodeType.name ? payload.__nodeType.name : null;
534
555
  }
535
556
  });
536
557
  var NodeInterface = NodeTC.getType();
537
- var getNodeInterface = (sc) => {
558
+ var getNodeInterface = sc => {
538
559
  if (sc.hasInstance("Node", import_graphql_compose3.InterfaceTypeComposer)) {
539
560
  return sc.get("Node");
540
561
  }
@@ -544,17 +565,12 @@ var getNodeInterface = (sc) => {
544
565
 
545
566
  // src/composeWithRelay/composeWithRelay.ts
546
567
  var TypeMapForRelayNode = {};
547
- var composeWithRelay = (tc) => {
568
+ var composeWithRelay = tc => {
548
569
  if (!(tc instanceof import_graphql_compose4.ObjectTypeComposer)) {
549
- throw new Error(
550
- "You should provide ObjectTypeComposer instance to composeWithRelay method"
551
- );
570
+ throw new Error("You should provide ObjectTypeComposer instance to composeWithRelay method");
552
571
  }
553
572
  const nodeInterface = getNodeInterface(tc.schemaComposer);
554
- const nodeFieldConfig = getNodeFieldConfig(
555
- TypeMapForRelayNode,
556
- nodeInterface
557
- );
573
+ const nodeFieldConfig = getNodeFieldConfig(TypeMapForRelayNode, nodeInterface);
558
574
  if (tc.getTypeName() === "Query" || tc.getTypeName() === "RootQuery") {
559
575
  tc.setField("node", nodeFieldConfig);
560
576
  return tc;
@@ -563,15 +579,11 @@ var composeWithRelay = (tc) => {
563
579
  return tc;
564
580
  }
565
581
  if (!tc.hasRecordIdFn()) {
566
- throw new Error(
567
- `ObjectTypeComposer(${tc.getTypeName()}) should have recordIdFn. This function returns ID from provided object.`
568
- );
582
+ throw new Error(`ObjectTypeComposer(${tc.getTypeName()}) should have recordIdFn. This function returns ID from provided object.`);
569
583
  }
570
584
  const findById = tc.getResolver("findById");
571
585
  if (!findById) {
572
- throw new Error(
573
- `ObjectTypeComposer(${tc.getTypeName()}) provided to composeWithRelay should have findById resolver.`
574
- );
586
+ throw new Error(`ObjectTypeComposer(${tc.getTypeName()}) provided to composeWithRelay should have findById resolver.`);
575
587
  }
576
588
  TypeMapForRelayNode[tc.getTypeName()] = {
577
589
  resolver: findById,
@@ -581,7 +593,7 @@ var composeWithRelay = (tc) => {
581
593
  id: {
582
594
  type: "ID!",
583
595
  description: "The globally unique ID among all types",
584
- resolve: (source) => {
596
+ resolve: source => {
585
597
  return toGlobalId(tc.getTypeName(), tc.getRecordId(source));
586
598
  }
587
599
  }
@@ -604,4 +616,4 @@ var import_graphql_compose_connection = __toESM(require("graphql-compose-connect
604
616
  createAppSyncResolverHandler,
605
617
  fromGlobalId,
606
618
  toGlobalId
607
- });
619
+ });
package/dist/server.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
2
  "use strict";
3
+
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -7,26 +8,32 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
7
8
  var __getProtoOf = Object.getPrototypeOf;
8
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
10
  var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
12
15
  };
13
16
  var __copyProps = (to, from, except, desc) => {
14
17
  if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
+ get: () => from[key],
20
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
+ });
18
22
  }
19
23
  return to;
20
24
  };
21
25
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
26
+ // If the importer is in node compatibility mode or this is not an ESM
27
+ // file that has been converted to a CommonJS file using a Babel-
28
+ // compatible transform (i.e. "__esModule" has not been set), then set
29
+ // "default" to the CommonJS "module.exports" for node compatibility.
30
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
31
+ value: mod,
32
+ enumerable: true
33
+ }) : target, mod));
34
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
35
+ value: true
36
+ }), mod);
30
37
 
31
38
  // src/server.ts
32
39
  var server_exports = {};
@@ -52,7 +59,11 @@ var createServer = ({
52
59
  res.send((0, import_graphql_helix.renderGraphiQL)());
53
60
  return;
54
61
  }
55
- const { operationName, query, variables } = (0, import_graphql_helix.getGraphQLParameters)(request);
62
+ const {
63
+ operationName,
64
+ query,
65
+ variables
66
+ } = (0, import_graphql_helix.getGraphQLParameters)(request);
56
67
  const result = await (0, import_graphql_helix.processRequest)({
57
68
  operationName,
58
69
  query,
@@ -67,4 +78,4 @@ var createServer = ({
67
78
  // Annotate the CommonJS export names for ESM import in node:
68
79
  0 && (module.exports = {
69
80
  createServer
70
- });
81
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/appsync-api",
3
- "version": "0.10.5",
3
+ "version": "0.10.7",
4
4
  "description": "A library for building GraphQL APIs for AWS AppSync.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "ttoss",
@@ -33,7 +33,7 @@
33
33
  "sideEffects": false,
34
34
  "typings": "dist/index.d.ts",
35
35
  "dependencies": {
36
- "@ttoss/cloudformation": "^0.6.4",
36
+ "@ttoss/cloudformation": "^0.6.6",
37
37
  "express": "^4.18.2",
38
38
  "graphql-compose-connection": "^8.2.1",
39
39
  "graphql-helix": "^1.13.0",
@@ -44,10 +44,10 @@
44
44
  "graphql-compose": "^9.0.10"
45
45
  },
46
46
  "devDependencies": {
47
- "@ttoss/config": "^1.29.1",
48
- "@ttoss/relay-amplify": "^0.4.2",
47
+ "@ttoss/config": "^1.29.2",
48
+ "@ttoss/relay-amplify": "^0.4.3",
49
49
  "@types/aws-lambda": "^8.10.111",
50
- "carlin": "^1.26.2",
50
+ "carlin": "^1.26.4",
51
51
  "graphql": "^16.6.0",
52
52
  "graphql-compose": "^9.0.10"
53
53
  },
@@ -70,5 +70,5 @@
70
70
  ]
71
71
  }
72
72
  },
73
- "gitHead": "ee0c2e51d38f37f997c020d4303cf90be720ecb0"
73
+ "gitHead": "01701f2c03d9872297d85af0a33d1ca4c2a6eb6b"
74
74
  }