@@ -985,6 +985,51 @@ describe('AppSyncModelVisitor', () => {
985
985
} ) ;
986
986
} ) ;
987
987
988
+ describe ( 'manyToMany with @auth directive' , ( ) => {
989
+ it ( 'should correctly process @auth directive in manyToMany relation' , ( ) => {
990
+ const schema = /* GraphQL */ `
991
+ type Post @model @auth(rules: [
992
+ { allow: groups, groups: ["Admins"] },
993
+ { allow: public, operations: [read] },
994
+ { allow: private, operations: [create] }
995
+ ]){
996
+ slug: ID! @primaryKey
997
+ title: String!
998
+ content: String!
999
+ tags: [Tag] @manyToMany(relationName: "PostTag")
1000
+ }
1001
+
1002
+ type Tag @model @auth(rules: [
1003
+ { allow: groups, groups: ["Admins"] },
1004
+ { allow: public, operations: [read] },
1005
+ { allow: private, operations: [create] }
1006
+ ]){
1007
+ name: ID! @primaryKey
1008
+ posts: [Post] @manyToMany(relationName: "PostTag")
1009
+ }
1010
+ ` ;
1011
+
1012
+ const { models } = createAndGenerateVisitor ( schema , { usePipelinedTransformer : true , respectPrimaryKeyAttributesOnConnectionField : true , transformerVersion : 2 } ) ;
1013
+
1014
+ const jointTableModel = models . PostTag ;
1015
+ const authDirective = jointTableModel . directives . find ( d => d . name === 'auth' ) ;
1016
+
1017
+ expect ( authDirective ) . toBeDefined ( ) ;
1018
+ expect ( authDirective ! . arguments . rules ) . toEqual ( [
1019
+ {
1020
+ allow : 'groups' ,
1021
+ groups : [ 'Admins' ] ,
1022
+ operations : [ 'create' , 'update' , 'delete' , 'read' ] ,
1023
+ groupClaim : 'cognito:groups' ,
1024
+ groupField : undefined ,
1025
+ provider : 'userPools' ,
1026
+ } ,
1027
+ { allow : 'public' , operations : [ 'read' ] } ,
1028
+ { allow : 'private' , operations : [ 'create' ] } ,
1029
+ ] ) ;
1030
+ } ) ;
1031
+ } ) ;
1032
+
988
1033
describe ( 'Primary Key Type' , ( ) => {
989
1034
describe ( 'V1 GraphQL schema tests' , ( ) => {
990
1035
const schemaV1 = /* GraphQL */ `
0 commit comments