@ttoss/appsync-api 0.5.1 → 0.7.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.
- package/dist/esm/{chunk-7AZ2LNJP.js → chunk-PZ5B6I7R.js} +49 -3
- package/dist/esm/cli.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +49 -3
- package/package.json +2 -2
- package/src/createApiTemplate.ts +62 -3
|
@@ -539,7 +539,7 @@ var getPackageLambdaLayerStackName = (packageName) => {
|
|
|
539
539
|
// package.json
|
|
540
540
|
var package_default = {
|
|
541
541
|
name: "@ttoss/appsync-api",
|
|
542
|
-
version: "0.
|
|
542
|
+
version: "0.7.0",
|
|
543
543
|
description: "A library for building GraphQL APIs for AWS AppSync.",
|
|
544
544
|
license: "UNLICENSED",
|
|
545
545
|
author: "ttoss",
|
|
@@ -614,7 +614,9 @@ var AppSyncGraphQLApiLogicalId = "AppSyncGraphQLApi";
|
|
|
614
614
|
var AppSyncGraphQLSchemaLogicalId = "AppSyncGraphQLSchema";
|
|
615
615
|
var AppSyncLambdaFunctionLogicalId = "AppSyncLambdaFunction";
|
|
616
616
|
var AppSyncLambdaFunctionAppSyncDataSourceLogicalId = "AppSyncLambdaFunctionAppSyncDataSource";
|
|
617
|
+
var AppSyncGraphQLApiKeyLogicalId = "AppSyncGraphQLApiKey";
|
|
617
618
|
var createApiTemplate = ({
|
|
619
|
+
apiKey,
|
|
618
620
|
schemaComposer,
|
|
619
621
|
dataSource,
|
|
620
622
|
lambdaFunction
|
|
@@ -669,7 +671,7 @@ var createApiTemplate = ({
|
|
|
669
671
|
[AppSyncGraphQLApiLogicalId]: {
|
|
670
672
|
Type: "AWS::AppSync::GraphQLApi",
|
|
671
673
|
Properties: {
|
|
672
|
-
AuthenticationType: "
|
|
674
|
+
AuthenticationType: "AWS_IAM",
|
|
673
675
|
Name: {
|
|
674
676
|
"Fn::Join": [
|
|
675
677
|
":",
|
|
@@ -717,10 +719,28 @@ var createApiTemplate = ({
|
|
|
717
719
|
}
|
|
718
720
|
},
|
|
719
721
|
Outputs: {
|
|
720
|
-
|
|
722
|
+
AppSyncApiGraphQLUrl: {
|
|
723
|
+
Export: {
|
|
724
|
+
Name: {
|
|
725
|
+
"Fn::Join": [
|
|
726
|
+
":",
|
|
727
|
+
[{ Ref: "AWS::StackName" }, "AppSyncApiGraphQLUrl"]
|
|
728
|
+
]
|
|
729
|
+
}
|
|
730
|
+
},
|
|
721
731
|
Value: {
|
|
722
732
|
"Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "GraphQLUrl"]
|
|
723
733
|
}
|
|
734
|
+
},
|
|
735
|
+
AppSyncApiArn: {
|
|
736
|
+
Export: {
|
|
737
|
+
Name: {
|
|
738
|
+
"Fn::Join": [":", [{ Ref: "AWS::StackName" }, "AppSyncApiArn"]]
|
|
739
|
+
}
|
|
740
|
+
},
|
|
741
|
+
Value: {
|
|
742
|
+
"Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "Arn"]
|
|
743
|
+
}
|
|
724
744
|
}
|
|
725
745
|
}
|
|
726
746
|
};
|
|
@@ -741,6 +761,32 @@ var createApiTemplate = ({
|
|
|
741
761
|
}
|
|
742
762
|
};
|
|
743
763
|
});
|
|
764
|
+
if (apiKey) {
|
|
765
|
+
template.Resources[AppSyncGraphQLApiLogicalId].Properties.AdditionalAuthenticationProvider = [
|
|
766
|
+
{
|
|
767
|
+
AuthenticationType: "API_KEY"
|
|
768
|
+
}
|
|
769
|
+
];
|
|
770
|
+
template.Resources[AppSyncGraphQLApiKeyLogicalId] = {
|
|
771
|
+
Type: "AWS::AppSync::ApiKey",
|
|
772
|
+
Properties: {
|
|
773
|
+
ApiId: { "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"] }
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
if (!template.Outputs) {
|
|
777
|
+
template.Outputs = {};
|
|
778
|
+
}
|
|
779
|
+
template.Outputs[AppSyncGraphQLApiKeyLogicalId] = {
|
|
780
|
+
Value: {
|
|
781
|
+
"Fn::GetAtt": [AppSyncGraphQLApiKeyLogicalId, "ApiKey"]
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
if (lambdaFunction.environment?.variables) {
|
|
786
|
+
template.Resources[AppSyncLambdaFunctionLogicalId].Properties.Environment = {
|
|
787
|
+
Variables: lambdaFunction.environment.variables
|
|
788
|
+
};
|
|
789
|
+
}
|
|
744
790
|
return template;
|
|
745
791
|
};
|
|
746
792
|
|
package/dist/esm/cli.js
CHANGED
package/dist/esm/index.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -6,12 +6,16 @@ import { AppSyncResolverHandler as AppSyncResolverHandler$1 } from 'aws-lambda';
|
|
|
6
6
|
type Role = string | {
|
|
7
7
|
'Fn::ImportValue': string;
|
|
8
8
|
};
|
|
9
|
-
declare const createApiTemplate: ({ schemaComposer, dataSource, lambdaFunction, }: {
|
|
9
|
+
declare const createApiTemplate: ({ apiKey, schemaComposer, dataSource, lambdaFunction, }: {
|
|
10
|
+
apiKey?: boolean | undefined;
|
|
10
11
|
schemaComposer: SchemaComposer<any>;
|
|
11
12
|
dataSource: {
|
|
12
13
|
roleArn: Role;
|
|
13
14
|
};
|
|
14
15
|
lambdaFunction: {
|
|
16
|
+
environment?: {
|
|
17
|
+
variables: Record<string, string>;
|
|
18
|
+
};
|
|
15
19
|
roleArn: Role;
|
|
16
20
|
};
|
|
17
21
|
}) => CloudFormationTemplate;
|
package/dist/index.js
CHANGED
|
@@ -572,7 +572,7 @@ var getPackageLambdaLayerStackName = (packageName) => {
|
|
|
572
572
|
// package.json
|
|
573
573
|
var package_default = {
|
|
574
574
|
name: "@ttoss/appsync-api",
|
|
575
|
-
version: "0.
|
|
575
|
+
version: "0.7.0",
|
|
576
576
|
description: "A library for building GraphQL APIs for AWS AppSync.",
|
|
577
577
|
license: "UNLICENSED",
|
|
578
578
|
author: "ttoss",
|
|
@@ -647,7 +647,9 @@ var AppSyncGraphQLApiLogicalId = "AppSyncGraphQLApi";
|
|
|
647
647
|
var AppSyncGraphQLSchemaLogicalId = "AppSyncGraphQLSchema";
|
|
648
648
|
var AppSyncLambdaFunctionLogicalId = "AppSyncLambdaFunction";
|
|
649
649
|
var AppSyncLambdaFunctionAppSyncDataSourceLogicalId = "AppSyncLambdaFunctionAppSyncDataSource";
|
|
650
|
+
var AppSyncGraphQLApiKeyLogicalId = "AppSyncGraphQLApiKey";
|
|
650
651
|
var createApiTemplate = ({
|
|
652
|
+
apiKey,
|
|
651
653
|
schemaComposer: schemaComposer2,
|
|
652
654
|
dataSource,
|
|
653
655
|
lambdaFunction
|
|
@@ -702,7 +704,7 @@ var createApiTemplate = ({
|
|
|
702
704
|
[AppSyncGraphQLApiLogicalId]: {
|
|
703
705
|
Type: "AWS::AppSync::GraphQLApi",
|
|
704
706
|
Properties: {
|
|
705
|
-
AuthenticationType: "
|
|
707
|
+
AuthenticationType: "AWS_IAM",
|
|
706
708
|
Name: {
|
|
707
709
|
"Fn::Join": [
|
|
708
710
|
":",
|
|
@@ -750,10 +752,28 @@ var createApiTemplate = ({
|
|
|
750
752
|
}
|
|
751
753
|
},
|
|
752
754
|
Outputs: {
|
|
753
|
-
|
|
755
|
+
AppSyncApiGraphQLUrl: {
|
|
756
|
+
Export: {
|
|
757
|
+
Name: {
|
|
758
|
+
"Fn::Join": [
|
|
759
|
+
":",
|
|
760
|
+
[{ Ref: "AWS::StackName" }, "AppSyncApiGraphQLUrl"]
|
|
761
|
+
]
|
|
762
|
+
}
|
|
763
|
+
},
|
|
754
764
|
Value: {
|
|
755
765
|
"Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "GraphQLUrl"]
|
|
756
766
|
}
|
|
767
|
+
},
|
|
768
|
+
AppSyncApiArn: {
|
|
769
|
+
Export: {
|
|
770
|
+
Name: {
|
|
771
|
+
"Fn::Join": [":", [{ Ref: "AWS::StackName" }, "AppSyncApiArn"]]
|
|
772
|
+
}
|
|
773
|
+
},
|
|
774
|
+
Value: {
|
|
775
|
+
"Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "Arn"]
|
|
776
|
+
}
|
|
757
777
|
}
|
|
758
778
|
}
|
|
759
779
|
};
|
|
@@ -774,6 +794,32 @@ var createApiTemplate = ({
|
|
|
774
794
|
}
|
|
775
795
|
};
|
|
776
796
|
});
|
|
797
|
+
if (apiKey) {
|
|
798
|
+
template.Resources[AppSyncGraphQLApiLogicalId].Properties.AdditionalAuthenticationProvider = [
|
|
799
|
+
{
|
|
800
|
+
AuthenticationType: "API_KEY"
|
|
801
|
+
}
|
|
802
|
+
];
|
|
803
|
+
template.Resources[AppSyncGraphQLApiKeyLogicalId] = {
|
|
804
|
+
Type: "AWS::AppSync::ApiKey",
|
|
805
|
+
Properties: {
|
|
806
|
+
ApiId: { "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"] }
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
if (!template.Outputs) {
|
|
810
|
+
template.Outputs = {};
|
|
811
|
+
}
|
|
812
|
+
template.Outputs[AppSyncGraphQLApiKeyLogicalId] = {
|
|
813
|
+
Value: {
|
|
814
|
+
"Fn::GetAtt": [AppSyncGraphQLApiKeyLogicalId, "ApiKey"]
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
if (lambdaFunction.environment?.variables) {
|
|
819
|
+
template.Resources[AppSyncLambdaFunctionLogicalId].Properties.Environment = {
|
|
820
|
+
Variables: lambdaFunction.environment.variables
|
|
821
|
+
};
|
|
822
|
+
}
|
|
777
823
|
return template;
|
|
778
824
|
};
|
|
779
825
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/appsync-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "A library for building GraphQL APIs for AWS AppSync.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
]
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "17a62817bc08beb436ba6f2a1a1a5262a913d67f"
|
|
72
72
|
}
|
package/src/createApiTemplate.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { getPackageLambdaLayerStackName } from 'carlin/src/deploy/lambdaLayer/ge
|
|
|
3
3
|
import packageJson from '../package.json';
|
|
4
4
|
import type { CloudFormationTemplate } from '@ttoss/cloudformation';
|
|
5
5
|
|
|
6
|
-
const AppSyncGraphQLApiLogicalId = 'AppSyncGraphQLApi';
|
|
6
|
+
export const AppSyncGraphQLApiLogicalId = 'AppSyncGraphQLApi';
|
|
7
7
|
|
|
8
8
|
export const AppSyncGraphQLSchemaLogicalId = 'AppSyncGraphQLSchema';
|
|
9
9
|
|
|
@@ -12,6 +12,8 @@ export const AppSyncLambdaFunctionLogicalId = 'AppSyncLambdaFunction';
|
|
|
12
12
|
const AppSyncLambdaFunctionAppSyncDataSourceLogicalId =
|
|
13
13
|
'AppSyncLambdaFunctionAppSyncDataSource';
|
|
14
14
|
|
|
15
|
+
export const AppSyncGraphQLApiKeyLogicalId = 'AppSyncGraphQLApiKey';
|
|
16
|
+
|
|
15
17
|
type Role =
|
|
16
18
|
| string
|
|
17
19
|
| {
|
|
@@ -19,15 +21,20 @@ type Role =
|
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
export const createApiTemplate = ({
|
|
24
|
+
apiKey,
|
|
22
25
|
schemaComposer,
|
|
23
26
|
dataSource,
|
|
24
27
|
lambdaFunction,
|
|
25
28
|
}: {
|
|
29
|
+
apiKey?: boolean;
|
|
26
30
|
schemaComposer: SchemaComposer<any>;
|
|
27
31
|
dataSource: {
|
|
28
32
|
roleArn: Role;
|
|
29
33
|
};
|
|
30
34
|
lambdaFunction: {
|
|
35
|
+
environment?: {
|
|
36
|
+
variables: Record<string, string>;
|
|
37
|
+
};
|
|
31
38
|
roleArn: Role;
|
|
32
39
|
};
|
|
33
40
|
}): CloudFormationTemplate => {
|
|
@@ -96,7 +103,7 @@ export const createApiTemplate = ({
|
|
|
96
103
|
[AppSyncGraphQLApiLogicalId]: {
|
|
97
104
|
Type: 'AWS::AppSync::GraphQLApi',
|
|
98
105
|
Properties: {
|
|
99
|
-
AuthenticationType: '
|
|
106
|
+
AuthenticationType: 'AWS_IAM',
|
|
100
107
|
Name: {
|
|
101
108
|
'Fn::Join': [
|
|
102
109
|
':',
|
|
@@ -148,11 +155,29 @@ export const createApiTemplate = ({
|
|
|
148
155
|
},
|
|
149
156
|
},
|
|
150
157
|
Outputs: {
|
|
151
|
-
|
|
158
|
+
AppSyncApiGraphQLUrl: {
|
|
159
|
+
Export: {
|
|
160
|
+
Name: {
|
|
161
|
+
'Fn::Join': [
|
|
162
|
+
':',
|
|
163
|
+
[{ Ref: 'AWS::StackName' }, 'AppSyncApiGraphQLUrl'],
|
|
164
|
+
],
|
|
165
|
+
},
|
|
166
|
+
},
|
|
152
167
|
Value: {
|
|
153
168
|
'Fn::GetAtt': [AppSyncGraphQLApiLogicalId, 'GraphQLUrl'],
|
|
154
169
|
},
|
|
155
170
|
},
|
|
171
|
+
AppSyncApiArn: {
|
|
172
|
+
Export: {
|
|
173
|
+
Name: {
|
|
174
|
+
'Fn::Join': [':', [{ Ref: 'AWS::StackName' }, 'AppSyncApiArn']],
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
Value: {
|
|
178
|
+
'Fn::GetAtt': [AppSyncGraphQLApiLogicalId, 'Arn'],
|
|
179
|
+
},
|
|
180
|
+
},
|
|
156
181
|
},
|
|
157
182
|
};
|
|
158
183
|
|
|
@@ -174,5 +199,39 @@ export const createApiTemplate = ({
|
|
|
174
199
|
};
|
|
175
200
|
});
|
|
176
201
|
|
|
202
|
+
if (apiKey) {
|
|
203
|
+
template.Resources[
|
|
204
|
+
AppSyncGraphQLApiLogicalId
|
|
205
|
+
].Properties.AdditionalAuthenticationProvider = [
|
|
206
|
+
{
|
|
207
|
+
AuthenticationType: 'API_KEY',
|
|
208
|
+
},
|
|
209
|
+
];
|
|
210
|
+
|
|
211
|
+
template.Resources[AppSyncGraphQLApiKeyLogicalId] = {
|
|
212
|
+
Type: 'AWS::AppSync::ApiKey',
|
|
213
|
+
Properties: {
|
|
214
|
+
ApiId: { 'Fn::GetAtt': [AppSyncGraphQLApiLogicalId, 'ApiId'] },
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
if (!template.Outputs) {
|
|
219
|
+
template.Outputs = {};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
template.Outputs[AppSyncGraphQLApiKeyLogicalId] = {
|
|
223
|
+
Value: {
|
|
224
|
+
'Fn::GetAtt': [AppSyncGraphQLApiKeyLogicalId, 'ApiKey'],
|
|
225
|
+
},
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (lambdaFunction.environment?.variables) {
|
|
230
|
+
template.Resources[AppSyncLambdaFunctionLogicalId].Properties.Environment =
|
|
231
|
+
{
|
|
232
|
+
Variables: lambdaFunction.environment.variables,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
177
236
|
return template;
|
|
178
237
|
};
|