@@ -28,6 +28,7 @@ import { sortFields } from '../utils/sort';
28
28
import { printWarning } from '../utils/warn' ;
29
29
import { processAuthDirective } from '../utils/process-auth' ;
30
30
import { processConnectionsV2 } from '../utils/process-connections-v2' ;
31
+ import { graphqlName , toUpper } from 'graphql-transformer-common' ;
31
32
32
33
export enum CodeGenGenerateEnum {
33
34
metadata = 'metadata' ,
@@ -603,7 +604,7 @@ export class AppSyncModelVisitor<
603
604
let directiveIndex = context . field . directives . indexOf ( context . directive , 0 ) ;
604
605
if ( directiveIndex > - 1 ) {
605
606
context . field . directives . splice ( directiveIndex , 1 ) ;
606
- context . field . type = context . directive . arguments . relationName ;
607
+ context . field . type = graphqlName ( toUpper ( context . directive . arguments . relationName ) ) ;
607
608
context . field . directives . push ( {
608
609
name : 'hasMany' ,
609
610
arguments : { indexName : `by${ context . model . name } ` , fields : [ this . determinePrimaryKeyFieldname ( context . model ) ] }
@@ -622,7 +623,7 @@ export class AppSyncModelVisitor<
622
623
model . fields . forEach ( field => {
623
624
field . directives . forEach ( dir => {
624
625
if ( dir . name === 'manyToMany' ) {
625
- let relationName = dir . arguments . relationName ;
626
+ let relationName = graphqlName ( toUpper ( dir . arguments . relationName ) ) ;
626
627
let existingRelation = manyDirectiveMap . get ( relationName ) ;
627
628
if ( existingRelation ) {
628
629
existingRelation . push ( { model : model , field : field , directive : dir } ) ;
@@ -640,7 +641,7 @@ export class AppSyncModelVisitor<
640
641
if ( value . length != 2 ) {
641
642
throw new Error ( `Error for relation: '${ value [ 0 ] . directive . arguments . relationName } ', there should be two matching manyToMany directives and found: ${ value . length } ` ) ;
642
643
}
643
- let intermediateModel = this . generateIntermediateModel ( value [ 0 ] . model , value [ 1 ] . model , value [ 0 ] . field , value [ 1 ] . field , value [ 0 ] . directive . arguments . relationName ) ;
644
+ let intermediateModel = this . generateIntermediateModel ( value [ 0 ] . model , value [ 1 ] . model , value [ 0 ] . field , value [ 1 ] . field , graphqlName ( toUpper ( value [ 0 ] . directive . arguments . relationName ) ) ) ;
644
645
const modelDirective = intermediateModel . directives . find ( directive => directive . name === 'model' ) ;
645
646
if ( modelDirective ) {
646
647
this . ensureIdField ( intermediateModel ) ;
0 commit comments