File tree Expand file tree Collapse file tree 2 files changed +27
-4
lines changed
Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ describe("test rumble abilities", async () => {
115115 ) . toEqual ( 10 ) ;
116116 } ) ;
117117
118- test ( "deny indirect read with helper implementation on one to one" , async ( ) => {
118+ test ( "error indirect read with helper implementation on one to one with error on non nullable relationship " , async ( ) => {
119119 rumble . abilityBuilder . comments . allow ( [ "read" ] ) ;
120120
121121 const { executor, yogaInstance } = build ( ) ;
@@ -140,6 +140,26 @@ describe("test rumble abilities", async () => {
140140 ] ) ;
141141 } ) ;
142142
143+ test ( "deny indirect read with helper implementation on one to one with error on nullable relationship" , async ( ) => {
144+ rumble . abilityBuilder . comments . allow ( [ "read" ] ) ;
145+
146+ const { executor, yogaInstance } = build ( ) ;
147+ const r = await executor ( {
148+ document : parse ( /* GraphQL */ `
149+ query {
150+ findManyComments {
151+ id
152+ post {
153+ id
154+ }
155+ }
156+ }
157+ ` ) ,
158+ } ) ;
159+
160+ expect ( ( r as any ) . data . findManyComments . length ) . toEqual ( 10 ) ;
161+ } ) ;
162+
143163 test ( "allow indirect read with helper implementation on one to one" , async ( ) => {
144164 rumble . abilityBuilder . comments . allow ( [ "read" ] ) ;
145165 rumble . abilityBuilder . users . allow ( [ "read" ] ) ;
Original file line number Diff line number Diff line change @@ -37,9 +37,12 @@ export const comments = table("comments", {
3737 postId : t . text ( "post_id" ) . references ( ( ) => posts . id , {
3838 onDelete : "cascade" ,
3939 } ) ,
40- ownerId : t . text ( "owner_id" ) . references ( ( ) => users . id , {
41- onDelete : "cascade" ,
42- } ) ,
40+ ownerId : t
41+ . text ( "owner_id" )
42+ . notNull ( )
43+ . references ( ( ) => users . id , {
44+ onDelete : "cascade" ,
45+ } ) ,
4346} ) ;
4447
4548export const usersRelations = relations ( users , ( { one, many } ) => ( {
You can’t perform that action at this time.
0 commit comments