@@ -20,23 +20,7 @@ const resolverPathMap = {
20
20
class ServerlessAppSyncSimulator {
21
21
constructor ( serverless ) {
22
22
this . serverless = serverless ;
23
- this . options = merge (
24
- {
25
- apiKey : '0123456789' ,
26
- port : 20002 ,
27
- wsPort : 20003 ,
28
- location : '.' ,
29
- refMap : { } ,
30
- getAttMap : { } ,
31
- dynamoDb : {
32
- endpoint : `http://localhost:${ get ( this . serverless . service , 'custom.dynamodb.start.port' , 8000 ) } ` ,
33
- region : 'localhost' ,
34
- accessKeyId : 'DEFAULT_ACCESS_KEY' ,
35
- secretAccessKey : 'DEFAULT_SECRET' ,
36
- } ,
37
- } ,
38
- get ( this . serverless . service , 'custom.appsync-simulator' , { } ) ,
39
- ) ;
23
+ this . options = null ;
40
24
this . log = this . log . bind ( this ) ;
41
25
this . debugLog = this . debugLog . bind ( this ) ;
42
26
@@ -67,6 +51,7 @@ class ServerlessAppSyncSimulator {
67
51
68
52
async startServer ( ) {
69
53
try {
54
+ this . buildResolvedOptions ( ) ;
70
55
this . buildResourceResolvers ( ) ;
71
56
this . serverless . service . functions = this . resolveResources (
72
57
this . serverless . service . functions ,
@@ -90,11 +75,14 @@ class ServerlessAppSyncSimulator {
90
75
? this . serverless . service . custom . appSync [ 0 ]
91
76
: this . serverless . service . custom . appSync ;
92
77
93
- const config = getAppSyncConfig ( {
94
- plugin : this ,
95
- serverless : this . serverless ,
96
- options : this . options ,
97
- } , appSync ) ;
78
+ const config = getAppSyncConfig (
79
+ {
80
+ plugin : this ,
81
+ serverless : this . serverless ,
82
+ options : this . options ,
83
+ } ,
84
+ appSync ,
85
+ ) ;
98
86
99
87
this . debugLog ( `AppSync Config ${ appSync . name } ` ) ;
100
88
this . debugLog ( inspect ( config , { depth : 4 , colors : true } ) ) ;
@@ -134,6 +122,30 @@ class ServerlessAppSyncSimulator {
134
122
} ;
135
123
}
136
124
125
+ buildResolvedOptions ( ) {
126
+ this . options = merge (
127
+ {
128
+ apiKey : '0123456789' ,
129
+ port : 20002 ,
130
+ wsPort : 20003 ,
131
+ location : '.' ,
132
+ refMap : { } ,
133
+ getAttMap : { } ,
134
+ dynamoDb : {
135
+ endpoint : `http://localhost:${ get (
136
+ this . serverless . service ,
137
+ 'custom.dynamodb.start.port' ,
138
+ 8000 ,
139
+ ) } `,
140
+ region : 'localhost' ,
141
+ accessKeyId : 'DEFAULT_ACCESS_KEY' ,
142
+ secretAccessKey : 'DEFAULT_SECRET' ,
143
+ } ,
144
+ } ,
145
+ get ( this . serverless . service , 'custom.appsync-simulator' , { } ) ,
146
+ ) ;
147
+ }
148
+
137
149
/**
138
150
* Resolves resourses through `Ref:` or `Fn:GetAtt`
139
151
*/
0 commit comments