@@ -80,11 +80,11 @@ void describe('convertSchemaToCDK', () => {
8080 echo(message: String!): String!
8181 }
8282 ` ;
83- const convertedDefinition = convertSchemaToCDK (
84- graphqlSchema ,
85- secretResolver ,
83+ const convertedDefinition = convertSchemaToCDK ( {
84+ schema : graphqlSchema ,
85+ backendSecretResolver : secretResolver ,
8686 stableBackendIdentifiers,
87- ) ;
87+ } ) ;
8888 assert . deepEqual ( convertedDefinition . schema , graphqlSchema ) ;
8989 assert . deepEqual ( convertedDefinition . dataSourceStrategies , {
9090 Todo : {
@@ -107,11 +107,11 @@ void describe('convertSchemaToCDK', () => {
107107 } ) ,
108108 } )
109109 . authorization ( ( allow ) => allow . publicApiKey ( ) ) ;
110- const convertedDefinition = convertSchemaToCDK (
111- typedSchema ,
112- secretResolver ,
110+ const convertedDefinition = convertSchemaToCDK ( {
111+ schema : typedSchema ,
112+ backendSecretResolver : secretResolver ,
113113 stableBackendIdentifiers,
114- ) ;
114+ } ) ;
115115 assert . deepEqual (
116116 removeWhiteSpaceForComparison ( convertedDefinition . schema ) ,
117117 removeWhiteSpaceForComparison ( expectedGraphqlSchema ) ,
@@ -135,11 +135,11 @@ void describe('convertSchemaToCDK', () => {
135135 } ) ,
136136 } )
137137 . authorization ( ( allow ) => allow . publicApiKey ( ) ) ;
138- const convertedDefinition = convertSchemaToCDK (
139- typedSchema ,
140- secretResolver ,
138+ const convertedDefinition = convertSchemaToCDK ( {
139+ schema : typedSchema ,
140+ backendSecretResolver : secretResolver ,
141141 stableBackendIdentifiers,
142- ) ;
142+ } ) ;
143143 assert . deepEqual ( convertedDefinition . dataSourceStrategies , {
144144 Todo : {
145145 dbType : 'DYNAMODB' ,
@@ -152,12 +152,12 @@ void describe('convertSchemaToCDK', () => {
152152 } ) ;
153153 } ) ;
154154
155- void it ( 'uses the only appropriate dbType and provisioningStrategy' , ( ) => {
156- const convertedDefinition = convertSchemaToCDK (
157- 'type Todo @model @auth(rules: { allow: public }) { id: ID! }' ,
158- secretResolver ,
155+ void it ( 'uses the default dbType and provisioningStrategy' , ( ) => {
156+ const convertedDefinition = convertSchemaToCDK ( {
157+ schema : 'type Todo @model @auth(rules: { allow: public }) { id: ID! }' ,
158+ backendSecretResolver : secretResolver ,
159159 stableBackendIdentifiers,
160- ) ;
160+ } ) ;
161161 assert . equal (
162162 Object . values ( convertedDefinition . dataSourceStrategies ) . length ,
163163 1 ,
@@ -198,11 +198,11 @@ void describe('convertSchemaToCDK', () => {
198198 . authorization ( ( allow ) => allow . publicApiKey ( ) ) ,
199199 } ) ;
200200
201- const convertedDefinition = convertSchemaToCDK (
202- modified ,
203- secretResolver ,
201+ const convertedDefinition = convertSchemaToCDK ( {
202+ schema : modified ,
203+ backendSecretResolver : secretResolver ,
204204 stableBackendIdentifiers,
205- ) ;
205+ } ) ;
206206
207207 assert . equal (
208208 Object . values ( convertedDefinition . dataSourceStrategies ) . length ,
@@ -253,11 +253,11 @@ void describe('convertSchemaToCDK', () => {
253253 . authorization ( ( allow ) => allow . publicApiKey ( ) ) ,
254254 } ) ;
255255
256- const convertedDefinition = convertSchemaToCDK (
257- modified ,
258- secretResolver ,
256+ const convertedDefinition = convertSchemaToCDK ( {
257+ schema : modified ,
258+ backendSecretResolver : secretResolver ,
259259 stableBackendIdentifiers,
260- ) ;
260+ } ) ;
261261
262262 assert . equal (
263263 Object . values ( convertedDefinition . dataSourceStrategies ) . length ,
@@ -337,11 +337,11 @@ void describe('convertSchemaToCDK', () => {
337337 . authorization ( ( allow ) => allow . publicApiKey ( ) ) ,
338338 } ) ;
339339
340- const convertedDefinition = convertSchemaToCDK (
341- modified ,
342- secretResolver ,
340+ const convertedDefinition = convertSchemaToCDK ( {
341+ schema : modified ,
342+ backendSecretResolver : secretResolver ,
343343 stableBackendIdentifiers,
344- ) ;
344+ } ) ;
345345
346346 assert . equal (
347347 Object . values ( convertedDefinition . dataSourceStrategies ) . length ,
@@ -420,11 +420,11 @@ void describe('convertSchemaToCDK', () => {
420420 . authorization ( ( allow ) => allow . publicApiKey ( ) ) ,
421421 } ) ;
422422
423- const convertedDefinition = convertSchemaToCDK (
424- modified ,
425- secretResolver ,
423+ const convertedDefinition = convertSchemaToCDK ( {
424+ schema : modified ,
425+ backendSecretResolver : secretResolver ,
426426 stableBackendIdentifiers,
427- ) ;
427+ } ) ;
428428
429429 assert . equal (
430430 Object . values ( convertedDefinition . dataSourceStrategies ) . length ,
@@ -480,11 +480,11 @@ void describe('convertSchemaToCDK', () => {
480480 . authorization ( ( allow ) => allow . publicApiKey ( ) ) ,
481481 } ) ;
482482
483- const convertedDefinition = convertSchemaToCDK (
484- modified ,
485- secretResolver ,
483+ const convertedDefinition = convertSchemaToCDK ( {
484+ schema : modified ,
485+ backendSecretResolver : secretResolver ,
486486 stableBackendIdentifiers,
487- ) ;
487+ } ) ;
488488
489489 assert . equal (
490490 Object . values ( convertedDefinition . dataSourceStrategies ) . length ,
@@ -514,4 +514,33 @@ void describe('convertSchemaToCDK', () => {
514514 } ,
515515 ) ;
516516 } ) ;
517+
518+ void it ( 'produces IMPORTED strategy for importedTableName' , ( ) => {
519+ const result = convertSchemaToCDK ( {
520+ schema : 'type Todo @model { id: ID! }' ,
521+ backendSecretResolver : secretResolver ,
522+ stableBackendIdentifiers,
523+ importedTableName : 'ExistingTable' ,
524+ } ) ;
525+ assert . deepEqual ( Object . values ( result . dataSourceStrategies ) [ 0 ] , {
526+ dbType : 'DYNAMODB' ,
527+ provisionStrategy : 'IMPORTED_AMPLIFY_TABLE' ,
528+ tableName : 'ExistingTable' ,
529+ } ) ;
530+ } ) ;
531+
532+ void it ( 'produces ADOPTED strategy for shouldAdoptExistingTable' , ( ) => {
533+ const result = convertSchemaToCDK ( {
534+ schema : 'type Todo @model { id: ID! }' ,
535+ backendSecretResolver : secretResolver ,
536+ stableBackendIdentifiers,
537+ importedTableName : 'AdoptedTable' ,
538+ shouldAdoptExistingTable : true ,
539+ } ) ;
540+ assert . deepEqual ( Object . values ( result . dataSourceStrategies ) [ 0 ] , {
541+ dbType : 'DYNAMODB' ,
542+ provisionStrategy : 'ADOPTED_AMPLIFY_TABLE' ,
543+ tableName : 'AdoptedTable' ,
544+ } ) ;
545+ } ) ;
517546} ) ;
0 commit comments