@@ -294,9 +294,8 @@ export class AppSyncModelVisitor<
294
294
}
295
295
processDirectives ( ) {
296
296
if ( this . config . usePipelinedTransformer || this . config . transformerVersion === 2 ) {
297
- this . processConnectionDirectivesV2 ( )
298
- }
299
- else {
297
+ this . processConnectionDirectivesV2 ( ) ;
298
+ } else {
300
299
this . processConnectionDirective ( ) ;
301
300
}
302
301
this . processAuthDirectives ( ) ;
@@ -441,9 +440,10 @@ export class AppSyncModelVisitor<
441
440
const typeArr : any [ ] = [ ] ;
442
441
Object . values ( { ...this . modelMap , ...this . nonModelMap } ) . forEach ( ( obj : CodeGenModel ) => {
443
442
// include only key directive as we don't care about others for versioning
444
- const directives = ( this . config . usePipelinedTransformer || this . config . transformerVersion === 2 )
445
- ? obj . directives . filter ( dir => dir . name === 'primaryKey' || dir . name === 'index' )
446
- : obj . directives . filter ( dir => dir . name === 'key' ) ;
443
+ const directives =
444
+ this . config . usePipelinedTransformer || this . config . transformerVersion === 2
445
+ ? obj . directives . filter ( dir => dir . name === 'primaryKey' || dir . name === 'index' )
446
+ : obj . directives . filter ( dir => dir . name === 'key' ) ;
447
447
const fields = obj . fields
448
448
. map ( ( field : CodeGenField ) => {
449
449
// include only connection field and type
@@ -633,7 +633,7 @@ export class AppSyncModelVisitor<
633
633
Object . values ( this . modelMap ) . forEach ( model => {
634
634
model . fields . forEach ( field => {
635
635
field . directives . forEach ( dir => {
636
- if ( dir . name === 'manyToMany' ) {
636
+ if ( dir . name === 'manyToMany' ) {
637
637
let relationName = graphqlName ( toUpper ( dir . arguments . relationName ) ) ;
638
638
let existingRelation = manyDirectiveMap . get ( relationName ) ;
639
639
if ( existingRelation ) {
@@ -679,7 +679,7 @@ export class AppSyncModelVisitor<
679
679
model . fields . forEach ( field => {
680
680
const connectionInfo = processConnectionsV2 ( field , model , this . modelMap ) ;
681
681
if ( connectionInfo ) {
682
- if ( connectionInfo . kind === CodeGenConnectionType . HAS_MANY ) {
682
+ if ( connectionInfo . kind === CodeGenConnectionType . HAS_MANY || connectionInfo . kind === CodeGenConnectionType . HAS_ONE ) {
683
683
// Need to update the other side of the connection even if there is no connection directive
684
684
addFieldToModel ( connectionInfo . connectedModel , connectionInfo . associatedWith ) ;
685
685
} else if ( connectionInfo . targetName !== 'id' ) {
0 commit comments