@ttoss/appsync-api 0.8.4 → 0.9.1
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/esm/index.js +19 -6
- package/dist/index.d.ts +17 -15
- package/dist/index.js +19 -6
- package/package.json +6 -5
- package/src/createAppSyncResolverHandler.ts +17 -2
package/dist/esm/index.js
CHANGED
|
@@ -79,7 +79,7 @@ var getPackageLambdaLayerStackName = (packageName) => {
|
|
|
79
79
|
// package.json
|
|
80
80
|
var package_default = {
|
|
81
81
|
name: "@ttoss/appsync-api",
|
|
82
|
-
version: "0.
|
|
82
|
+
version: "0.9.1",
|
|
83
83
|
description: "A library for building GraphQL APIs for AWS AppSync.",
|
|
84
84
|
license: "UNLICENSED",
|
|
85
85
|
author: "ttoss",
|
|
@@ -112,7 +112,7 @@ var package_default = {
|
|
|
112
112
|
sideEffects: false,
|
|
113
113
|
typings: "dist/index.d.ts",
|
|
114
114
|
dependencies: {
|
|
115
|
-
"@ttoss/cloudformation": "^0.
|
|
115
|
+
"@ttoss/cloudformation": "^0.6.1",
|
|
116
116
|
express: "^4.18.2",
|
|
117
117
|
"graphql-compose-connection": "^8.2.1",
|
|
118
118
|
"graphql-helix": "^1.13.0",
|
|
@@ -123,9 +123,10 @@ var package_default = {
|
|
|
123
123
|
"graphql-compose": "^9.0.10"
|
|
124
124
|
},
|
|
125
125
|
devDependencies: {
|
|
126
|
-
"@ttoss/config": "^1.28.
|
|
126
|
+
"@ttoss/config": "^1.28.3",
|
|
127
|
+
"@ttoss/relay-amplify": "^0.3.1",
|
|
127
128
|
"@types/aws-lambda": "^8.10.111",
|
|
128
|
-
carlin: "^1.
|
|
129
|
+
carlin: "^1.24.1",
|
|
129
130
|
graphql: "^16.6.0",
|
|
130
131
|
"graphql-compose": "^9.0.10"
|
|
131
132
|
},
|
|
@@ -373,19 +374,31 @@ var createApiTemplate = ({
|
|
|
373
374
|
return template;
|
|
374
375
|
};
|
|
375
376
|
|
|
377
|
+
// ../relay-amplify/src/encodeCredentials.ts
|
|
378
|
+
var decodeCredentials = (credentials) => {
|
|
379
|
+
return JSON.parse(Buffer.from(credentials, "base64").toString("utf8"));
|
|
380
|
+
};
|
|
381
|
+
|
|
376
382
|
// src/createAppSyncResolverHandler.ts
|
|
377
383
|
var createAppSyncResolverHandler = ({
|
|
378
384
|
schemaComposer: schemaComposer2
|
|
379
385
|
}) => {
|
|
380
386
|
return async (event, context) => {
|
|
381
|
-
const { info, arguments: args, source } = event;
|
|
387
|
+
const { info, arguments: args, source, request } = event;
|
|
382
388
|
const { parentTypeName, fieldName } = info;
|
|
389
|
+
const credentials = (() => {
|
|
390
|
+
const headersCredentials = request?.headers?.["x-credentials"];
|
|
391
|
+
if (!headersCredentials) {
|
|
392
|
+
return null;
|
|
393
|
+
}
|
|
394
|
+
return decodeCredentials(headersCredentials);
|
|
395
|
+
})();
|
|
383
396
|
const resolveMethods = schemaComposer2.getResolveMethods();
|
|
384
397
|
const resolver = resolveMethods[parentTypeName][fieldName];
|
|
385
398
|
return resolver(
|
|
386
399
|
source,
|
|
387
400
|
args,
|
|
388
|
-
{ ...context, identity: event.identity },
|
|
401
|
+
{ ...context, identity: event.identity, credentials },
|
|
389
402
|
info
|
|
390
403
|
);
|
|
391
404
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,22 @@ type Resource = {
|
|
|
21
21
|
Condition?: string;
|
|
22
22
|
Properties: any;
|
|
23
23
|
};
|
|
24
|
+
type Policy = {
|
|
25
|
+
PolicyName: string;
|
|
26
|
+
PolicyDocument: {
|
|
27
|
+
Version: '2012-10-17';
|
|
28
|
+
Statement: {
|
|
29
|
+
Sid?: string;
|
|
30
|
+
Effect: 'Allow' | 'Deny';
|
|
31
|
+
Action: string | string[];
|
|
32
|
+
Resource: string | string[] | {
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
} | {
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
}[];
|
|
37
|
+
}[];
|
|
38
|
+
};
|
|
39
|
+
};
|
|
24
40
|
type IAMRoleResource = Resource & {
|
|
25
41
|
Type: 'AWS::IAM::Role';
|
|
26
42
|
Properties: {
|
|
@@ -37,21 +53,7 @@ type IAMRoleResource = Resource & {
|
|
|
37
53
|
};
|
|
38
54
|
ManagedPolicyArns?: string[];
|
|
39
55
|
Path?: string;
|
|
40
|
-
Policies?:
|
|
41
|
-
PolicyName: string;
|
|
42
|
-
PolicyDocument: {
|
|
43
|
-
Version: '2012-10-17';
|
|
44
|
-
Statement: {
|
|
45
|
-
Effect: 'Allow' | 'Deny';
|
|
46
|
-
Action: string | string[];
|
|
47
|
-
Resource: string | string[] | {
|
|
48
|
-
[key: string]: any;
|
|
49
|
-
} | {
|
|
50
|
-
[key: string]: any;
|
|
51
|
-
}[];
|
|
52
|
-
}[];
|
|
53
|
-
};
|
|
54
|
-
}[];
|
|
56
|
+
Policies?: Policy[];
|
|
55
57
|
};
|
|
56
58
|
};
|
|
57
59
|
type Resources = {
|
package/dist/index.js
CHANGED
|
@@ -119,7 +119,7 @@ var getPackageLambdaLayerStackName = (packageName) => {
|
|
|
119
119
|
// package.json
|
|
120
120
|
var package_default = {
|
|
121
121
|
name: "@ttoss/appsync-api",
|
|
122
|
-
version: "0.
|
|
122
|
+
version: "0.9.1",
|
|
123
123
|
description: "A library for building GraphQL APIs for AWS AppSync.",
|
|
124
124
|
license: "UNLICENSED",
|
|
125
125
|
author: "ttoss",
|
|
@@ -152,7 +152,7 @@ var package_default = {
|
|
|
152
152
|
sideEffects: false,
|
|
153
153
|
typings: "dist/index.d.ts",
|
|
154
154
|
dependencies: {
|
|
155
|
-
"@ttoss/cloudformation": "^0.
|
|
155
|
+
"@ttoss/cloudformation": "^0.6.1",
|
|
156
156
|
express: "^4.18.2",
|
|
157
157
|
"graphql-compose-connection": "^8.2.1",
|
|
158
158
|
"graphql-helix": "^1.13.0",
|
|
@@ -163,9 +163,10 @@ var package_default = {
|
|
|
163
163
|
"graphql-compose": "^9.0.10"
|
|
164
164
|
},
|
|
165
165
|
devDependencies: {
|
|
166
|
-
"@ttoss/config": "^1.28.
|
|
166
|
+
"@ttoss/config": "^1.28.3",
|
|
167
|
+
"@ttoss/relay-amplify": "^0.3.1",
|
|
167
168
|
"@types/aws-lambda": "^8.10.111",
|
|
168
|
-
carlin: "^1.
|
|
169
|
+
carlin: "^1.24.1",
|
|
169
170
|
graphql: "^16.6.0",
|
|
170
171
|
"graphql-compose": "^9.0.10"
|
|
171
172
|
},
|
|
@@ -413,19 +414,31 @@ var createApiTemplate = ({
|
|
|
413
414
|
return template;
|
|
414
415
|
};
|
|
415
416
|
|
|
417
|
+
// ../relay-amplify/src/encodeCredentials.ts
|
|
418
|
+
var decodeCredentials = (credentials) => {
|
|
419
|
+
return JSON.parse(Buffer.from(credentials, "base64").toString("utf8"));
|
|
420
|
+
};
|
|
421
|
+
|
|
416
422
|
// src/createAppSyncResolverHandler.ts
|
|
417
423
|
var createAppSyncResolverHandler = ({
|
|
418
424
|
schemaComposer: schemaComposer2
|
|
419
425
|
}) => {
|
|
420
426
|
return async (event, context) => {
|
|
421
|
-
const { info, arguments: args, source } = event;
|
|
427
|
+
const { info, arguments: args, source, request } = event;
|
|
422
428
|
const { parentTypeName, fieldName } = info;
|
|
429
|
+
const credentials = (() => {
|
|
430
|
+
const headersCredentials = request?.headers?.["x-credentials"];
|
|
431
|
+
if (!headersCredentials) {
|
|
432
|
+
return null;
|
|
433
|
+
}
|
|
434
|
+
return decodeCredentials(headersCredentials);
|
|
435
|
+
})();
|
|
423
436
|
const resolveMethods = schemaComposer2.getResolveMethods();
|
|
424
437
|
const resolver = resolveMethods[parentTypeName][fieldName];
|
|
425
438
|
return resolver(
|
|
426
439
|
source,
|
|
427
440
|
args,
|
|
428
|
-
{ ...context, identity: event.identity },
|
|
441
|
+
{ ...context, identity: event.identity, credentials },
|
|
429
442
|
info
|
|
430
443
|
);
|
|
431
444
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/appsync-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
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.
|
|
36
|
+
"@ttoss/cloudformation": "^0.6.1",
|
|
37
37
|
"express": "^4.18.2",
|
|
38
38
|
"graphql-compose-connection": "^8.2.1",
|
|
39
39
|
"graphql-helix": "^1.13.0",
|
|
@@ -44,9 +44,10 @@
|
|
|
44
44
|
"graphql-compose": "^9.0.10"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@ttoss/config": "^1.28.
|
|
47
|
+
"@ttoss/config": "^1.28.3",
|
|
48
|
+
"@ttoss/relay-amplify": "^0.3.1",
|
|
48
49
|
"@types/aws-lambda": "^8.10.111",
|
|
49
|
-
"carlin": "^1.
|
|
50
|
+
"carlin": "^1.24.1",
|
|
50
51
|
"graphql": "^16.6.0",
|
|
51
52
|
"graphql-compose": "^9.0.10"
|
|
52
53
|
},
|
|
@@ -69,5 +70,5 @@
|
|
|
69
70
|
]
|
|
70
71
|
}
|
|
71
72
|
},
|
|
72
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "56e8cfde36a962deaa5514453618280699824b4f"
|
|
73
74
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { decodeCredentials } from '@ttoss/relay-amplify/src/encodeCredentials';
|
|
1
2
|
import type { AppSyncResolverHandler as AwsAppSyncResolverHandler } from 'aws-lambda';
|
|
2
3
|
import type { SchemaComposer } from 'graphql-compose';
|
|
3
4
|
|
|
@@ -13,14 +14,28 @@ export const createAppSyncResolverHandler = ({
|
|
|
13
14
|
schemaComposer: SchemaComposer<any>;
|
|
14
15
|
}): AppSyncResolverHandler<any, any, any> => {
|
|
15
16
|
return async (event, context) => {
|
|
16
|
-
const { info, arguments: args, source } = event;
|
|
17
|
+
const { info, arguments: args, source, request } = event;
|
|
18
|
+
|
|
17
19
|
const { parentTypeName, fieldName } = info;
|
|
20
|
+
|
|
21
|
+
const credentials = (() => {
|
|
22
|
+
const headersCredentials = request?.headers?.['x-credentials'];
|
|
23
|
+
|
|
24
|
+
if (!headersCredentials) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return decodeCredentials(headersCredentials);
|
|
29
|
+
})();
|
|
30
|
+
|
|
18
31
|
const resolveMethods = schemaComposer.getResolveMethods();
|
|
32
|
+
|
|
19
33
|
const resolver = (resolveMethods[parentTypeName] as any)[fieldName];
|
|
34
|
+
|
|
20
35
|
return resolver(
|
|
21
36
|
source,
|
|
22
37
|
args,
|
|
23
|
-
{ ...context, identity: event.identity },
|
|
38
|
+
{ ...context, identity: event.identity, credentials },
|
|
24
39
|
info
|
|
25
40
|
);
|
|
26
41
|
};
|