@@ -20,23 +20,7 @@ const resolverPathMap = {
2020class ServerlessAppSyncSimulator {
2121 constructor ( serverless ) {
2222 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 ;
4024 this . log = this . log . bind ( this ) ;
4125 this . debugLog = this . debugLog . bind ( this ) ;
4226
@@ -67,6 +51,7 @@ class ServerlessAppSyncSimulator {
6751
6852 async startServer ( ) {
6953 try {
54+ this . buildResolvedOptions ( ) ;
7055 this . buildResourceResolvers ( ) ;
7156 this . serverless . service . functions = this . resolveResources (
7257 this . serverless . service . functions ,
@@ -90,11 +75,14 @@ class ServerlessAppSyncSimulator {
9075 ? this . serverless . service . custom . appSync [ 0 ]
9176 : this . serverless . service . custom . appSync ;
9277
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+ ) ;
9886
9987 this . debugLog ( `AppSync Config ${ appSync . name } ` ) ;
10088 this . debugLog ( inspect ( config , { depth : 4 , colors : true } ) ) ;
@@ -134,6 +122,30 @@ class ServerlessAppSyncSimulator {
134122 } ;
135123 }
136124
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+
137149 /**
138150 * Resolves resourses through `Ref:` or `Fn:GetAtt`
139151 */
0 commit comments